Merged to one file. Encapsulating database functions.