Fixes for bugs M-316 and M-317.