Refactored model stuff into its own file