Several fixes and checks for properly building on Linux.