tidier IOError catching + remove some commented-out code