Fixed potential memory leak from boost shared_ptr misuse