Manually merged patch 2 into the most recent state.

This replaces Pull request #2