fixed compile errors when using Linux Mint 16 (-std=c++11 and std::isnan instead of isnan)
fixed valgrind errors