Fixes for compiling and Windows