Revert "Refactor most things for viewer, remove ugly code"

This reverts commit fffb06713a5b70b6f1c82f8a7a135b154a96b788.