Tracking fixes branched off 2.0

This pull request is to meged https://github.com/okfn/ckan/pull/730> into 2.0. I branched this off 2.0, cherry-picked all the commits from <https://github.com/okfn/ckan/pull/730>, core tests are passing, so are the tracking tests (from another branch).