Mem leaks2

@PimV @basvandenheuvel 
Memory leak fixes!! :)