Tweaks to error catching to prevent hangs
Whitespace & comment cleanup