Refactoring of Room and several bugfixes