Refactoring API to support the built-in libraries. Work in progress.