refactoring viewable and fixes from scrutinizer