Move the database stuff into its own file