Formatted an awful lot of code, refactored ugliness

Code in headers is much better structured, information that was known to
callers, but not to functions called therefrom, is now sunk into those
functions, rather than looked up again by the called functions. Also,
refactored the enormous CItem::DoSomeWork in item.cpp. Also added a few
functions in preparation for future re-design of CTreeList
datastructures.