Clean up endomorphism-related code