Starting documentation process

Added also some NULL evaluative statements, Doxygen comments and
expanded loops/ifs - for better readability.