Add usage samples, more tests, and minor cleanup.