Clean up some code, get CMD working.