Fixed third task

Fixed mistakes with object allocation and deallocation.