fixed error handling
fixed error handling
Minor cleanup