added some clear statements to help with memory management