add comments and improve cosmetics