code improvements
memory fix