Fix for bug(s) caught by tests.