Structure: fix all remaining bugs and a test case.