Refactored-out some model stuff into seperate file.