Code cleanup, prepare for Windows invasion