Cleanup code from pull request #2