Fixed some error catching and comments