Error handling and other changes