More fixes after merge with new database, also some refactoring, oops
Merge branch 'master' of https://github.com/sw701e14/code