memory leaks fixed except for sa