Three commits from BUG2 branch rolled together

BUG2 commit #1

BUG2 commit #2

BUG2 commit #3