Clean up code

This is a clean up of the backend code.