CODE CLEANUP: fixed some db utilities and cleaned up the server controller a bit

db utilities fixed and modified
cleaned up some server controls