Move all database stuff to new file