Fix CAF-316 and CAF-317.
Merge pull request #4020 from HassenRiahi/FixCAF316/317

Fix CAF-316 and CAF-317.