plugin: reorder some functions and add some documentation