Database fix

@AlexSYanai: Fixed all of the associations, etc. CAVEAT: Some of the field names have been re-factored for clarity, so some of the tests might break, can you double-check after merging?