Bug fix for #270 and #272.

This pull request reverts the old fix for issue 270 because it introduced another issue (#272). It also then fixes #270 correctly.