clean-up and add comments