Shuffle code around to please MSVC