Get database working and different bugfixes;