Changed code

Massive errors were found in the code after a database switch, this will
help in future updates