Fixed database errors, merging to master