Add top-level initializer. More tests.

Tests have uncovered some issues that needed to be fixed.