Clean up code, remove debugging procedure