Fixes to original PR.