API: improve code and performance.