Fixed code to avoid MSVC compiler crash because of 'internal error'