replaced some deletes with deleteLater()

and added delete to template in types.hpp