More fixes in viewer.js