clean up some annoying indents and error code checking.