More functions made dual API, and some cleanup.