Misc code cleanup and fixes
Fix syntax error that could have caused a NPE