fixed memory problem
fixed memory problem, re-added functionality