Tested in linux, fixed some bugs and removed some c++11 specific stuff.