FIX: AccessViolation due to shared_ptr lifetime