YAY! Refactor and tons of bugs squashed. I should start committing each
file separately so I can better track the changes...