Fixed memory leak

- now using shared_ptr (boost, std is for c++11)
- still missing fix for rules deletion (predicates problem, same solution)