Reorganized backend code