CRM-14885: adding generic dependencies & various optimizations.