Add cleanup/refactor portion of #2010 for hack and Dockerfile updates
Merge pull request #2051 from tianon/hack-dockerfile-refactor

Add cleanup/refactor portion of #2010 for hack and Dockerfile updates