The funny thing is, that I usually break things when I try clean up the code. When I just mindlessly add new features without caring much about optimization, it's less likely to break... :D
yeah optimization can be a pain (well at least to me as a beginer :p) well i guess here it was even more since you said you started again from scratch O.o, but as long as things work out well that's what matters :)