Robot fixes backported

Brought a few robot fixes from develop back into dev_5_0 and also found and fixed a couple of minor bugs in the dev_5_0 image viewer.

To test image viewer fixes:
 - Open image viewer. Click "color" checkbox. It should toggle greyscale (previously was broken on the first click).
 - Open the 'Edit' popup. Click on the same 'color' checkbox in the main window again. Check that the 'Render as color' checkbox in the Edit panel is kept in sync (and "Save" saves the current settings).