final cleanup of code for the new viewer