Add code documentation

Except for parse_config() which will be rewritten at a later time.