various corrections & error catching