Fixes #146 and other minor bugs in viewer