Fix small compatability issues and reorder code to POSIX

These few commits effectively adjust some of the code to work in POSIX environments (should work in most, unless I missed a few Linux-specific things), fix a tiny spelling mistake, some formatting shit, the usual.

Pretty much just a tiny cleanup, should be no issue and really doesn't change any functionality.