Added a test for #1583 and fixed the underlying problem.