Move more functions to internal utilities. Update docs.