Portable build

Portability changes (with commit history)