Fixes for compilation with GCC

I've fixed a number of issues I encountered with GCC 4.8 on Ubuntu 13.10. Not tested on any other OS.