Did a whole bunch of bugfixing and other stuff. Code should be simpler now, easier for noobs.