DISCL-235: Code review Friday refactorings

This is preliminary draft review
Done, using scoped_ptr<> for all. The code looks better and it seems order was not as important as it was before!