Reduced the cyclomatic complexity of several functions