Merged PR #357, Fixed #340.