Reorganize some functions and reference.