Refactor ORM and move components to sub directory