small fixes for final
small fixes
fixed deallocation