Cleaned up code

Resolved some warnings
Updated database

Implemented foreign key support