Now hash controls market and category history changes (buggy)

This is a big and kinda breaking commit.

Added several funcitons to handle the problems with hash and going
twards a more centralized db.cat and db.market varuable (that's
supposed to always be acurate).
Moved everything out of the global scope into "kdown"

Broken BTW.
Fixed a few more errors. new direction? get rid of all the hash stuff.
Made it so it works the way it should without the hash change.