tasks/ports functions refactored.