Using std/boost make_shared for creating shared pointers

Using make_shared for creating boost/std shared pointers will reduce the number of allocations
I also fixed boost::function nulling issue
Not sure - will make an experiment