Fixed C++11 compilation errors and a crash

I can make two separate pull requests for these two commits if you wish.