Refactoring, started using Shared Pointers