Big overhaul.

* No need for a struct, just alias an array and copy the key.
* Make errors first-class.
* Test error conditions.
Small cleanups.