improve comments and improve some parts of the code