Refactored to export public API