added some explanations and done some cleanup