Improve format, remove comented lines and add doc to some functions.