Refactoring: use namespace package + reorganize core API