Clean up code and made minor cosmetic changes