Fixed complexity and code quality.