Added captions to viewport code and cleaned it up