Clean up code, and registration