port functions refactored.