Adding array cleaning to remove empty entries.