Some fixes and tweaks for PR #309

Apologies for the inconvenience.