Fixed bugs in the server db functions