Added basic support for running within Docker, and various refactorings.