fix trailing whitespaces and apply some code guidelines