More progress on viewer and cleaner code using set and macros