Cleanup, better error handling

Code cleanup, resets to default settings in event of error (can't
handle all yet), undid some lines I commented out...