Code clean-up and formatting