Refactor and regroup function definitions
Replace `beginning-of-buffer' with `goto-char'

Fixes:

    Warning: `beginning-of-buffer' is for interactive use only; use
`(goto-char (point-min))' instead.