fixed passing of payloads via window messages to work properly on both Win32 and Win64
plus slightly more efficient pointer casting