Added memory management.