server code cleanup