Refactored previewer.py to be simpler and more pythonic.