Added handling of some errors