Fixed built errors
Reorganized database model