Cleanup and setup seem straight forward. When programming in general it is good to have sort of neutral states that you program will sit in most of the time. So, when you design your methods you can count on certain conditions being true, and you won't have to worry about not being quite right about what is going on in the program. Just make sure that you always end methods in one of these neutral states.
Hmm.. there would be a lot to talk about here if I don't have some general knowledge of what you think you have covered.
Think you could give me an idea of a game plan you have so far?
Edit: for debugging it is a good Idea to locate problems by eliminating potential problems by substituting complex algorithms out for default test values.
for example: you have a program that does this:
x = read in from a text file 2
y=function(x) //when x = 2 y should equal 5
write out y
now suppose your output is 'g'
what you should do is set y to 5 instead of function(x)
is the problem persists your write out is the problem.
if it does not set x to 2
if the problem persists then the function is the problem
if it does not then the read in is the problem