Started work on database code. Also, refactoring.