Cleanups to allow use in core and Win32 fixes

CC @karenetheridge