Created port.h, plus some code removal and refactoring.

is => if