Cleanup

Just a couple of pendantic things with error handling, plus some better comments.