Sideport upstream master fixes

This ports https://github.com/ckan/ckan/pull/1605 to our extension.