Moved static functions to the top

Also removed wrong doc comments and corrected a typo in another comment.