implemented most queries, have mostly cleaning up to do now.
merge