Windowed cmd fix on win os. Minor refactories.