add some comments; rename functions