Finished the DB adaptions

removed the reference class, and fixed a few bugs that were not fixed
earlier