major code refactor, switched to ORM