Fixes to POSIX version; kind of works now;