Eliminated dead code, fixed growing typeview

Before, if turned off and back on, the typeview would have an extra copy
of each item. Now, I clear the list of items first.
Refactored a bunch of C++03-style for-loops
Dead code removal, converted naked ptrs to smart...