Major refactor of auth, date query handling and a general tidy of the API.