Refactoring of store code

* Only create an array of store items when necessary for the UI
* Refactor ui-store to have fewer globals (should increase future flexibility)
* Localise store context menu code to ui-store.c & simplify
* Loads of other small cleanups, renamings, reformattings etc.