Bug 6537 - squashed version of the previous 5 commits, signed-off