Clean up top level API.
Move some helpers around.