More portability fixes

It still doesn't work on FreeBSD, but I just ran out of time
Add todo item so we don't forget to fix this later