Incorporating changes proposed in pull request #24 by fabaff