fix minor issues and reformatted code