Moved Query store into the API package. Future-proofing.

This moved the query-storage out of the webservice package and into the
api where it belongs. It also future proofs the system by allowing for
multiple different implementations of the protocol. Currently the only
existing one is an in-memory store, but this can be expanded with a
persistant store in the future. The QueryStore implementation itself has
a set of defined exceptional states, and returns strings as ids rather
than integers, so that alternate implementations can do what they like.
The current implementation has also been made life-cycle aware.