Database stuff complete

pls merge