few error handling fixes