Well, it's broken now... Don't use this commit :P
Refactored... about to begin testing
Fixed a lot of bugs