Code massaging and some cleanup