Make more posix compliant, move to subdir. probably needs some more work