Fix allocation bug