added several calls to finish to avoid any seg faults as result of deleting memory prematurely