Sprint5 bug fixes (develop)

As for PR 373, rebased onto develop.