Fixed stack corruption error