In many places magento calls count() just to check if array is empty. These places should be changed to use !empty() instead.