Still rearranging. Taking some style from the Scala API.