Replaced dynamic_cas with Ptr::dynamicCast<>, and & with &&