fair amount of code cleanup, some fixes for potential crashes
build updates for windows and os x
2.5.6dev