windows program cleanup and code optimization