Move port to main.
Add type signatures to functions.