Theme cleanup; more test cases; other small improvements