more fixes as per @jsha's suggestions in #256