Merged changes from https://github.com/Andrea/duality into this fork.