few fixes and formatting of the code