Internal API and doc improvements