Code improvements and clean-up.