Move from an array-based API to a hash-based API.

@bschwartz Want to take a quick peek at this before I merge? [client]