added some comments, modified several variables