replace ulong with unsigned long for MSVC compatibility