Visual Studio Compatibility Fix

Moved variable declarations to the top of functions or loops to maintain
VS compatibility as VS doesn't support C99 standard/
Merge pull request #9 from elaverick/master

Visual Studio Compatibility Fix