Move some functions and add some comments.