Reorganised code

I can actually find things now. I should remember to comment more also.
I also changed a couple of little things.