Refactor to clean up API a bit.