Fixed an issue causing memory corruption introduced with the previous commit