some tidying up to try to resolve issues with memory leaks