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

Why always posix?