added removing of allocated resources