removing unused code, adding comments, cleaning up