Fixes database stuff & various errors