Dhalperi track relations created

Add an API to lookup which datasets were created by a particular query, for the backend part of #580.

Also several misc cleanups, either warnings or just changing code that we've since learned how to author better.