Some fixes required to build on FreeBSD

FYI, the game works fine here and I was able to complete the story, although I've had transient segfaults, one after finishing a battle and one after saving a game. Will try to catch them.