Minor code cleaning, improved use of smart pointers