Fix jshint errors

Code has been refoactored and in some cases maxcomplexity setting
has been increased