various error catching improvements