Fix msvc compile error and improve 64 bit compatibility