Big cleanup of civicrm.views.inc

An attempt to clean up civicrm.views.inc, in particular to make the function civicrm_views_custom_data_cache() more easier to follow.

This shouldn't change any behaviour.