Added check for cyclomatic complexity

- Simplified some overly complex functions,
  told flake8 to ignore others