refactor and simplify the internal package structure