Back to bitbucket we go

:
Moved things around.
Separated DB logic from business logic. Also cleaned up code.