lots of cleanup - more windows compatibility