Fix possible stack corruption