fix memory leak; clean-up commented code