Refactored to split public API from implementation