improved error catching and comments.