added some roxygen comments (basis for documentation). commented the line that starts profiling.
added documentation for functions
some code cleanup. moved legend of grpah A to top left.