format2

added some changes of style and code using comments from previous commit