Major refactoring and Docker 1.0 compatibility