Clean up code, remove debug statements, rename hooks