major code refactoring - also extend list command to output most internal data structures to stdout