More fixes and some error handling