reformat code & fix some stuff