Integrated changes from Gabriele submitted as issues #23 & #24 on
github.