Contributed by Huachao and Peter Bacsko. Reviewed by Wilfred Spiegelenburg. (cherry picked from commit 6a4966f336c7b86a69d292b6157315e25963e527)