Refactoring, fixed leaks, switch to C++11 style

No more pointers to structures but copied(or moved?) classes, no news
std::arrays and general cleanup