Refactoring and cleanup.
Transition batch files to powershell.