Massive database refactor in order to fix database saving issues

tasellielund
wlparker
Fix redonculous printlns tasellielund wlparker
fix merge errors tasellilund wlparker