re-adding changes to fix #44, since there were collisions with changes for #55