Fixed some server functions. Misc. cleanup