MSVC Compiler Compatibility

Move variable declaration to the beginning of the block, for better C90 compliance. Should compile now in MSVC.