Added win32 console mode handling.
Also some more cleanup.

Signed-off-by: Peter Atashian <retep998@gmail.com>