Code cleanup.
New test.
Working on #225.