Refactoring (movement towards MVC, database operations clearly separated from the rest, more encapsulation)