Reorg bugfixes

@kariyngva please read over this pull request and give me some feedback.

I decided to give a little management structure (basically structuring the stuff I did by hand using ipython earlier when we updated the server). This is a first step in making the project nicer to work with and easier to understand (I hope).