fixed compilation on Windows; many minor coding style tweaks.