Change internal API and refactoring