memory leaks fixed + document updated