Optimize memory consuption by avoiding the creation of empty arrays