Code refactoring

Removed a lot of unused portions of code and restructured the code to
share pieces across install and deploy.