Remove unnecessary complexity and fix code style