Added more comments, cleaned out unused code