Fixed a compilation problem with GCC4.7

GCC 4.7 appears to be very unforgiving when it comes to the scope of variables.
This change solves the bug, but should also be ported to the different patches.