Fixed 2 memory leaks & added more comments.