minor fixes + error catching