Pr40 to master

Attempts to rework #40 for master integration.