some memory leaks here in there mostly fixed. Template is leaking the surface.