Reorganize cube_server code