Replace malloc with new