Code clean-up and comments