[ONOS-7175]: Refractor R Scripts that generate wiki result graphs in TestON.

- Code is "chunked"; blocks of code are sectioned into sub-steps.
- Many comments have been added and updated.
- Many console messages have been added and updated.

Change-Id: I86853b4a3917d807e634311b672ab6d6d57b1194
diff --git a/TestON/JenkinsFile/scripts/README.md b/TestON/JenkinsFile/scripts/README.md
new file mode 100644
index 0000000..dab3f68
--- /dev/null
+++ b/TestON/JenkinsFile/scripts/README.md
@@ -0,0 +1,23 @@
+<h1>Wiki Graph Scripts</h1>
+
+The scripts that generate the graphs are written in the R programming language.
+
+The scripts are structured in the following format:
+1. Data Management
+    * Data is obtained from the databases through SQL. CLI arguments, filename, and titles are also handled here.
+        1. Importing libraries
+        2. Command line arguments
+        3. Title of the graph
+        4. Filename
+        5. SQL Initialization and Data Gathering
+2. Organize Data
+    * Raw data is sorted into a data frame.  The data frame is used in generating the graph.
+        1. Combining data into a single list.
+        2. Using the list to construct a data frame
+        3. Adding data as columns to the data frame
+3. Generate Graphs
+    * The graphs are formatted and constructed here.
+        1. Main plot generated
+        2. Fundamental variables assigned
+        3. Generate specific graph format
+        4. Exporting graph to file
diff --git a/TestON/JenkinsFile/scripts/SCPFIntentInstallWithdrawRerouteLat.R b/TestON/JenkinsFile/scripts/SCPFIntentInstallWithdrawRerouteLat.R
index 76352e8..93e9e00 100644
--- a/TestON/JenkinsFile/scripts/SCPFIntentInstallWithdrawRerouteLat.R
+++ b/TestON/JenkinsFile/scripts/SCPFIntentInstallWithdrawRerouteLat.R
@@ -21,172 +21,308 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 9 ] ) ){
-    print( "Usage: Rscript SCPFIntentInstallWithdrawRerouteLat.R <isFlowObj> <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <batch-size> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFIntentInstallWithdrawRerouteLat.R",
+                                  "<isFlowObj>" ,
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<batch-size>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-flowObjFileModifier <- ""
-if ( args[ 1 ] == "y" ){
-    flowObjFileModifier <- "fobj_"
-}
+# -----------------------------------
+# Create File Name and Title of Graph
+# -----------------------------------
 
-# paste() is used to concatenate strings
-errBarOutputFile <- paste( args[ 9 ], "SCPFIntentInstallWithdrawRerouteLat", sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 7 ], sep="_" )
+print( "Creating filename and title of graph." )
+
+chartTitle <- "Intent Install, Withdraw, & Reroute Latencies"
+flowObjFileModifier <- ""
+errBarOutputFile <- paste( args[ 9 ],
+                    "SCPFIntentInstallWithdrawRerouteLat_",
+                    args[ 7 ],
+                    sep="" )
+
 if ( args[ 1 ] == "y" ){
     errBarOutputFile <- paste( errBarOutputFile, "_fobj", sep="" )
+    flowObjFileModifier <- "fobj_"
+    chartTitle <- paste( chartTitle, "w/ FlowObj" )
 }
-errBarOutputFile <- paste( errBarOutputFile, "_", sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 8 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, "-batchSize", sep="" )
-errBarOutputFile <- paste( errBarOutputFile, "_graph.jpg", sep="" )
 
-print( "Reading from databases." )
+errBarOutputFile <- paste( errBarOutputFile,
+                           "_",
+                           args[ 8 ],
+                           "-batchSize_graph.jpg",
+                           sep="" )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 2 ], port=strtoi( args[ 3 ] ), user=args[ 4 ],password=args[ 5 ] )
+chartTitle <- paste( chartTitle,
+                     "\nBatch Size =",
+                     args[ 8 ],
+                     sep=" " )
 
-command1 <- paste( "SELECT * FROM intent_latency_", flowObjFileModifier, sep="" )
-command1 <- paste( command1, "tests WHERE batch_size=", sep="" )
-command1 <- paste( command1, args[ 8 ], sep="" )
-command1 <- paste( command1, " AND branch = '", sep="" )
-command1 <- paste( command1, args[ 7 ], sep="" )
-command1 <- paste( command1, "' AND date IN ( SELECT MAX( date ) FROM intent_latency_", sep="" )
-command1 <- paste( command1, flowObjFileModifier, sep="" )
-command1 <- paste( command1,  "tests WHERE branch='", sep="" )
-command1 <- paste( command1,  args[ 7 ], sep="" )
-command1 <- paste( command1,  "')", sep="" )
+# ------------------
+# SQL Initialization
+# ------------------
 
-print( paste( "Sending SQL command:", command1 ) )
+print( "Initializing SQL" )
 
-fileData1 <- dbGetQuery( con, command1 )
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 2 ],
+                  port = strtoi( args[ 3 ] ),
+                  user = args[ 4 ],
+                  password = args[ 5 ] )
 
-command2 <- paste( "SELECT * FROM intent_reroute_latency_", flowObjFileModifier, sep="" )
-command2 <- paste( command2, "tests WHERE batch_size=", sep="" )
-command2 <- paste( command2, args[ 8 ], sep="" )
-command2 <- paste( command2, " AND branch = '", sep="" )
-command2 <- paste( command2, args[ 7 ], sep="" )
-command2 <- paste( command2, "' AND date IN ( SELECT MAX( date ) FROM intent_reroute_latency_", sep="" )
-command2 <- paste( command2, flowObjFileModifier, sep="" )
-command2 <- paste( command2,  "tests WHERE branch='", sep="" )
-command2 <- paste( command2,  args[ 7 ], sep="" )
-command2 <- paste( command2,  "')", sep="" )
+# ---------------------------------------
+# Intent Install and Withdraw SQL Command
+# ---------------------------------------
+print( "Generating Intent Install and Withdraw SQL Command" )
 
-print( paste( "Sending SQL command:", command2 ) )
+installWithdrawSQLCommand <- paste( "SELECT * FROM intent_latency_",
+                                    flowObjFileModifier,
+                                    "tests WHERE batch_size=",
+                                    args[ 8 ],
+                                    " AND branch = '",
+                                    args[ 7 ],
+                                    "' AND date IN ( SELECT MAX( date ) FROM intent_latency_",
+                                    flowObjFileModifier,
+                                    "tests WHERE branch='",
+                                    args[ 7 ],
+                                    "')",
+                                    sep="" )
 
-fileData2 <- dbGetQuery( con, command2 )
+print( "Sending Intent Install and Withdraw SQL command:" )
+print( installWithdrawSQLCommand )
+installWithdrawData <- dbGetQuery( con, installWithdrawSQLCommand )
+
+# --------------------------
+# Intent Reroute SQL Command
+# --------------------------
+
+print( "Generating Intent Reroute SQL Command" )
+
+rerouteSQLCommand <- paste( "SELECT * FROM intent_reroute_latency_",
+                            flowObjFileModifier,
+                            "tests WHERE batch_size=",
+                            args[ 8 ],
+                            " AND branch = '",
+                            args[ 7 ],
+                            "' AND date IN ( SELECT MAX( date ) FROM intent_reroute_latency_",
+                            flowObjFileModifier,
+                            "tests WHERE branch='",
+                            args[ 7 ],
+                            "')",
+                            sep="" )
+
+print( "Sending Intent Reroute SQL command:" )
+print( rerouteSQLCommand )
+rerouteData <- dbGetQuery( con, rerouteSQLCommand )
 
 # **********************************************************
-# STEP 2: Organize data.
+# STEP 2: Organize Data.
 # **********************************************************
 
-print( "STEP 2: Organize data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-# Create lists c() and organize data into their corresponding list.
-print( "Sorting data." )
-if ( ncol( fileData2 ) == 0 ){
-    avgs <- c( fileData1[ 'install_avg' ], fileData1[ 'withdraw_avg' ] )
+# -------------------------------------------------------
+# Combining Install, Withdraw, and Reroute Latencies Data
+# -------------------------------------------------------
+
+print( "Combining Install, Withdraw, and Reroute Latencies Data" )
+
+if ( ncol( rerouteData ) == 0 ){  # Checks if rerouteData exists, so we can exclude it if necessary
+    avgs <- c( installWithdrawData[ 'install_avg' ],
+               installWithdrawData[ 'withdraw_avg' ] )
 } else{
-    colnames( fileData2 ) <- c( "date", "name", "date", "branch", "commit", "scale", "batch_size", "reroute_avg", "reroute_std" )
-    avgs <- c( fileData1[ 'install_avg' ], fileData1[ 'withdraw_avg' ], fileData2[ 'reroute_avg' ] )
+    colnames( rerouteData ) <- c( "date",
+                                  "name",
+                                  "date",
+                                  "branch",
+                                  "commit",
+                                  "scale",
+                                  "batch_size",
+                                  "reroute_avg",
+                                  "reroute_std" )
+
+    avgs <- c( installWithdrawData[ 'install_avg' ],
+               installWithdrawData[ 'withdraw_avg' ],
+               rerouteData[ 'reroute_avg' ] )
 }
 
-# Parse lists into data frames.
-dataFrame <- melt( avgs )              # This is where reshape2 comes in. Avgs list is converted to data frame
+# Combine lists into data frames.
+dataFrame <- melt( avgs )
 
-if ( ncol( fileData2 ) == 0 ){
-    dataFrame$scale <- c( fileData1$scale, fileData1$scale )      # Add node scaling to the data frame.
-    dataFrame$stds <- c( fileData1$install_std, fileData1$withdraw_std )
+# --------------------
+# Construct Data Frame
+# --------------------
+
+print( "Constructing data frame." )
+
+if ( ncol( rerouteData ) == 0 ){  # Checks if rerouteData exists (due to batch size) for the dataFrame this time
+    dataFrame$scale <- c( installWithdrawData$scale,
+                          installWithdrawData$scale )
+
+    dataFrame$stds <- c( installWithdrawData$install_std,
+                         installWithdrawData$withdraw_std )
 } else{
-    dataFrame$scale <- c( fileData1$scale, fileData1$scale, fileData2$scale )      # Add node scaling to the data frame.
-    dataFrame$stds <- c( fileData1$install_std, fileData1$withdraw_std, fileData2$reroute_std )
+    dataFrame$scale <- c( installWithdrawData$scale,
+                          installWithdrawData$scale,
+                          rerouteData$scale )
+
+    dataFrame$stds <- c( installWithdrawData$install_std,
+                         installWithdrawData$withdraw_std,
+                         rerouteData$reroute_std )
 }
-colnames( dataFrame ) <- c( "ms", "type", "scale", "stds" )
+
+colnames( dataFrame ) <- c( "ms",
+                            "type",
+                            "scale",
+                            "stds" )
 
 # Format data frame so that the data is in the same order as it appeared in the file.
 dataFrame$type <- as.character( dataFrame$type )
 dataFrame$type <- factor( dataFrame$type, levels=unique( dataFrame$type ) )
 
-dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
-
-
+dataFrame <- na.omit( dataFrame ) # Omit any data that doesn't exist
 
 print( "Data Frame Results:" )
 print( dataFrame )
 
 # **********************************************************
-# STEP 3: Generate graphs.
+# STEP 3: Generate graph.
 # **********************************************************
 
-print( "STEP 3: Generate graphs." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
 
-# 1. Graph fundamental data is generated first.
-#    These are variables that apply to all of the graphs being generated, regardless of type.
-#
-# 2. Type specific graph data is generated.
-#     Data specific for the error bar and stacked bar graphs are generated.
-#
-# 3. Generate and save the graphs.
-#      Graphs are saved to the filename above, in the directory provided in command line args
+# -------------------
+# Main Plot Generated
+# -------------------
+
+print( "Creating the main plot." )
+
+mainPlot <- ggplot( data = dataFrame, aes( x = scale,
+                                           y = ms,
+                                           ymin = ms,
+                                           ymax = ms + stds,
+                                           fill = type ) )
+
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
 
 print( "Generating fundamental graph data." )
 
-theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-
-mainPlot <- ggplot( data = dataFrame, aes( x = scale, y = ms, ymin = ms, ymax = ms + stds, fill = type ) )
-
-# Formatting the plot
-width <- 1.3  # Width of the bars.
-xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9) )
+theme_set( theme_grey( base_size = 22 ) )
+barWidth <- 1.3
+xScaleConfig <- scale_x_continuous( breaks = c( 1, 3, 5, 7, 9) )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Latency (ms)" )
 fillLabel <- labs( fill="Type" )
-chartTitle <- "Intent Install, Withdraw, & Reroute Latencies"
-if ( args[ 1 ] == "y" ){
-    chartTitle <- paste( chartTitle, "w/ FlowObj" )
-}
-chartTitle <- paste( chartTitle, "\nBatch Size =" )
-chartTitle <- paste( chartTitle, fileData1[ 1,'batch_size' ] )
+title <- ggtitle( chartTitle )
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+errorBarColor <- rgb( 140, 140, 140, maxColorValue=255 )
 
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
+theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ),
+                legend.position="bottom",
+                legend.text=element_text( size=22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
+
+colors <- scale_fill_manual( values=c( "#F77670",
+                                       "#619DFA",
+                                       "#18BA48" ) )
 
 # Store plot configurations as 1 variable
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        title +
+                        colors
 
-# Create the bar graph with error bars.
-# geom_bar contains:
-#    - stat: data formatting (usually "identity")
-#    - width: the width of the bar types (declared above)
-# geom_errorbar contains similar arguments as geom_bar.
+# ---------------------------
+# Generating Bar Graph Format
+# ---------------------------
+
 print( "Generating bar graph with error bars." )
-colors <- scale_fill_manual( values=c( "#F77670", "#619DFA", "#18BA48" ) )
-barGraphFormat <- geom_bar( stat = "identity", width = width, position = "dodge" )
-errorBarFormat <- geom_errorbar( width = width, position = position_dodge( width ), color=rgb( 140, 140, 140, maxColorValue=255 ) )
 
-title <- ggtitle( chartTitle )
-values <- geom_text( aes( x=dataFrame$scale, y=dataFrame$ms + 0.035 * max( dataFrame$ms ), label = format( dataFrame$ms, digits=3, big.mark = ",", scientific = FALSE ) ), position=position_dodge( width=width ), size = 5.5, fontface = "bold" )
-wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
-result <- fundamentalGraphData + barGraphFormat + colors + errorBarFormat + title + values + wrapLegend
+barGraphFormat <- geom_bar( stat = "identity",
+                            width = barWidth,
+                            position = "dodge" )
 
-# Save graph to file
+errorBarFormat <- geom_errorbar( width = barWidth,
+                                 position = position_dodge( barWidth ),
+                                 color = errorBarColor )
+
+values <- geom_text( aes( x = dataFrame$scale,
+                          y = dataFrame$ms + 0.035 * max( dataFrame$ms ),
+                          label = format( dataFrame$ms,
+                                          digits = 3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          position = position_dodge( width = barWidth ),
+                          size = 5.5,
+                          fontface = "bold" )
+
+wrapLegend <- guides( fill = guide_legend( nrow = 1, byrow = TRUE ) )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          errorBarFormat +
+          values +
+          wrapLegend
+
+# -----------------------
+# Exporting Graph to File
+# -----------------------
+
 print( paste( "Saving bar chart with error bars to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
-print( paste( "Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
+
+ggsave( errBarOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFLineGraph.R b/TestON/JenkinsFile/scripts/SCPFLineGraph.R
index 15451a4..f080a4d 100644
--- a/TestON/JenkinsFile/scripts/SCPFLineGraph.R
+++ b/TestON/JenkinsFile/scripts/SCPFLineGraph.R
@@ -22,58 +22,102 @@
 
 # This is the R script that generates the SCPF front page graphs.
 
+
 # **********************************************************
 # STEP 1: Data management.
 # **********************************************************
 
+print( "**********************************************************" )
 print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
-#                     RPostgreSQL: https://code.google.com/archive/p/rpostgresql/
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )
 
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 # Command line arguments are read. Args include the database credentials, test name, branch name, and the directory to output files.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
 # Check if sufficient args are provided.
 if ( is.na( args[ 10 ] ) ){
-    print( "Usage: Rscript testresultgraph.R <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <#-dates> <SQL-command> <y-axis> <directory-to-save-graph>" )
+
+    print( paste( "Usage: Rscript testresultgraph.R",
+                                    "<database-host>",
+                                    "<database-port>",
+                                    "<database-user-id>",
+                                    "<database-password>",
+                                    "<graph-title>",    # part of the output filename as well
+                                    "<branch-name>",    # part of the output filename
+                                    "<#-dates>",        # part of the output filename
+                                    "<SQL-command>",
+                                    "<y-axis-title>",   # y-axis may be different among other SCPF graphs (ie: batch size, latency, etc. )
+                                    "<directory-to-save-graph>",
+                  sep = " " ) )
+
     q()  # basically exit(), but in R
 }
 
-# Filenames for the output graph include the testname, branch, and the graph type.
+# -------------------------------
+# Create Title and Graph Filename
+# -------------------------------
 
-outputFile <- paste( args[ 10 ], "SCPF_Front_Page" , sep="" )
-outputFile <- paste( outputFile, gsub( " ", "_", args[ 5 ] ), sep="_" )
-outputFile <- paste( outputFile, args[ 6 ], sep="_" )
-outputFile <- paste( outputFile, args[ 7 ], sep="_" )
-outputFile <- paste( outputFile, "dates", sep="-" )
-outputFile <- paste( outputFile, "_graph.jpg", sep="" )
-
-# From RPostgreSQL
-print( "Reading from databases." )
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
-
-print( "Sending SQL command." )
-fileData <- dbGetQuery( con, args[ 8 ] )
+print( "Creating title of graph" )
 
 # Title of graph based on command line args.
 title <- args[ 5 ]
 
+print( "Creating graph filename." )
+
+# Filenames for the output graph include the testname, branch, and the graph type.
+outputFile <- paste( args[ 10 ],
+                    "SCPF_Front_Page_",
+                    gsub( " ", "_", args[ 5 ] ),
+                    "_",
+                    args[ 6 ],
+                    "_",
+                    args[ 7 ],
+                    "-dates_graph.jpg",
+                    sep="" )
+
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+print( "Sending SQL command:" )
+print( args[ 8 ] )
+fileData <- dbGetQuery( con, args[ 8 ] )
+
+
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "STEP 2: Organize data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
 # Create lists c() and organize data into their corresponding list.
-print( "Sorting data into new data frame." )
+print( "Combine data retrieved from databases into a list." )
 
 if ( ncol( fileData ) > 1 ){
     for ( i in 2:ncol( fileData ) ){
@@ -81,13 +125,17 @@
     }
 }
 
-# Parse lists into data frames.
-# This is where reshape2 comes in. Avgs list is converted to data frame.
-dataFrame <- melt( fileData )
+# --------------------
+# Construct Data Frame
+# --------------------
 
+print( "Constructing data frame from combined data." )
+
+dataFrame <- melt( fileData )
 dataFrame$date <- fileData$date
 
-colnames( dataFrame ) <- c( "Legend", "Values" )
+colnames( dataFrame ) <- c( "Legend",
+                            "Values" )
 
 # Format data frame so that the data is in the same order as it appeared in the file.
 dataFrame$Legend <- as.character( dataFrame$Legend )
@@ -105,7 +153,13 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
-print( "STEP 3: Generate graphs." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
+
+# -------------------
+# Main Plot Generated
+# -------------------
 
 print( "Creating main plot." )
 # Create the primary plot here.
@@ -115,35 +169,91 @@
 #        - x: x-axis values (usually iterative, but it will become date # later)
 #        - y: y-axis values (usually tests)
 #        - color: the category of the colored lines (usually legend of test)
-theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-mainPlot <- ggplot( data = dataFrame, aes( x = iterative, y = Values, color = Legend ) )
+
+mainPlot <- ggplot( data = dataFrame, aes( x = iterative,
+                                           y = Values,
+                                           color = Legend ) )
+
+# -------------------
+# Main Plot Formatted
+# -------------------
 
 print( "Formatting main plot." )
 
-# Store plot configurations as 1 variable
-fundamentalGraphData <- mainPlot + expand_limits( y = 0 )
+limitExpansion <- expand_limits( y = 0 )
 
-yScaleConfig <- scale_y_continuous( breaks = seq( 0, max( dataFrame$Values ) * 1.05, by = ceiling( max( dataFrame$Values ) / 10 ) ) )
+maxYDisplay <- max( dataFrame$Values ) * 1.05
+yBreaks <- ceiling( max( dataFrame$Values ) / 10 )
+yScaleConfig <- scale_y_continuous( breaks = seq( 0, maxYDisplay, by = yBreaks ) )
 
-xLabel <- xlab( "Time" )
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
+
+print( "Generating fundamental graph data." )
+
+theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
+xLabel <- xlab( "Build" )
 yLabel <- ylab( args[ 9 ] )
-fillLabel <- labs( fill="Type" )
-legendLabels <- scale_colour_discrete( labels = names( fileData ) )
-centerTitle <- theme( plot.title=element_text( hjust = 0.5 ) )  # To center the title text
-theme <- theme( axis.text.x = element_blank(), axis.ticks.x = element_blank(), plot.title = element_text( size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ), legend.direction = 'horizontal' )
-colors <- scale_color_manual( values=c( "#111111", "#008CFF", "#FF3700", "#00E043", "#EEB600", "#E500FF") )
-wrapLegend <- guides( color=guide_legend( nrow=2, byrow=TRUE ) )
 
-fundamentalGraphData <- fundamentalGraphData + yScaleConfig + xLabel + yLabel + fillLabel + legendLabels + centerTitle + theme + colors
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+
+# Set other graph configurations here.
+theme <- theme( axis.text.x = element_blank(),
+                axis.ticks.x = element_blank(),
+                plot.title = element_text( size = 32, face='bold', hjust = 0.5 ),
+                legend.position = "bottom",
+                legend.text = element_text( size=22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ),
+                legend.direction = 'horizontal' )
+
+# Colors used for the lines.
+# Note: graphs that have X lines will use the first X colors in this list.
+colors <- scale_color_manual( values=c( "#111111",   # black
+                                        "#008CFF",   # blue
+                                        "#FF3700",   # red
+                                        "#00E043",   # green
+                                        "#EEB600",   # yellow
+                                        "#E500FF") ) # purple (not used)
+
+wrapLegend <- guides( color = guide_legend( nrow = 2, byrow = TRUE ) )
+title <- ggtitle( title )
+
+fundamentalGraphData <- mainPlot +
+                        limitExpansion +
+                        yScaleConfig +
+                        xLabel +
+                        yLabel +
+                        theme +
+                        colors +
+                        wrapLegend +
+                        title
+
+# ----------------------------
+# Generating Line Graph Format
+# ----------------------------
+
 print( "Generating line graph." )
 
 lineGraphFormat <- geom_line( size = 0.75 )
 pointFormat <- geom_point( size = 1.75 )
-title <- ggtitle( title )
 
-result <- fundamentalGraphData + lineGraphFormat + pointFormat + title + wrapLegend
+result <- fundamentalGraphData +
+          lineGraphFormat +
+          pointFormat
 
-# Save graph to file
+# -----------------------
+# Exporting Graph to File
+# -----------------------
+
 print( paste( "Saving result graph to", outputFile ) )
-ggsave( outputFile, width = 15, height = 10, dpi = 200 )
-print( paste( "Successfully wrote result graph out to", outputFile ) )
+
+ggsave( outputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote result graph out to", outputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFbatchFlowResp.R b/TestON/JenkinsFile/scripts/SCPFbatchFlowResp.R
index 8d0b6b4..d63bce3 100644
--- a/TestON/JenkinsFile/scripts/SCPFbatchFlowResp.R
+++ b/TestON/JenkinsFile/scripts/SCPFbatchFlowResp.R
@@ -21,164 +21,337 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 7 ] ) ){
-    print( "Usage: Rscript SCPFbatchFlowResp <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFbatchFlowResp",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-errBarOutputFile <- paste( args[ 7 ], args[ 5 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 6 ], sep="_" )
-errBarOutputFile <- paste( errBarOutputFile, "_PostGraph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-print( "Reading from databases." )
+print( "Creating filenames and title of graph." )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
+postOutputFile <- paste( args[ 7 ],
+                         args[ 5 ],
+                         "_",
+                         args[ 6 ],
+                         "_PostGraph.jpg",
+                         sep="" )
 
-command <- paste( "SELECT * FROM batch_flow_tests WHERE branch='", args[ 6 ], sep="" )
-command <- paste( command, "' ORDER BY date DESC LIMIT 3", sep="" )
+delOutputFile <- paste( args[ 7 ],
+                        args[ 5 ],
+                        "_",
+                        args[ 6 ],
+                        "_DelGraph.jpg",
+                        sep="" )
 
-print( paste( "Sending SQL command:", command ) )
+postChartTitle <- paste( "Single Bench Flow Latency - Post", "Last 3 Builds", sep = "\n" )
+delChartTitle <- paste( "Single Bench Flow Latency - Del", "Last 3 Builds", sep = "\n" )
+
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# ---------------------------
+# Batch Flow Resp SQL Command
+# ---------------------------
+
+print( "Generating Batch Flow Resp SQL Command" )
+
+command <- paste( "SELECT * FROM batch_flow_tests WHERE branch='",
+                  args[ 6 ],
+                  "' ORDER BY date DESC LIMIT 3",
+                  sep="" )
+
+print( "Sending SQL command:" )
+print( command )
 
 fileData <- dbGetQuery( con, command )
 
-chartTitle <- paste( "Single Bench Flow Latency - Post", "Last 3 Builds", sep = "\n" )
 
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-avgs <- c()
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-print( "Sorting data." )
-avgs <- c( fileData[ 'posttoconfrm' ], fileData[ 'elapsepost' ] )
+# -----------------
+# Post Data Sorting
+# -----------------
 
-dataFrame <- melt( avgs )
-dataFrame$scale <- fileData$scale
-dataFrame$date <- fileData$date
-dataFrame$iterative <- dataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) )
+print( "Sorting data for Post." )
 
-colnames( dataFrame ) <- c( "ms", "type", "scale", "date", "iterative" )
+postAvgs <- c( fileData[ 'posttoconfrm' ],
+               fileData[ 'elapsepost' ] )
+
+# -------------------------
+# Post Construct Data Frame
+# -------------------------
+
+postDataFrame <- melt( postAvgs )
+postDataFrame$scale <- fileData$scale
+postDataFrame$date <- fileData$date
+postDataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) )
+
+colnames( postDataFrame ) <- c( "ms",
+                                "type",
+                                "scale",
+                                "date",
+                                "iterative" )
 
 # Format data frame so that the data is in the same order as it appeared in the file.
-dataFrame$type <- as.character( dataFrame$type )
-dataFrame$type <- factor( dataFrame$type, levels=unique( dataFrame$type ) )
+postDataFrame$type <- as.character( postDataFrame$type )
+postDataFrame$type <- factor( postDataFrame$type,
+                              levels = unique( postDataFrame$type ) )
 
-dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
+postDataFrame <- na.omit( postDataFrame )   # Omit any data that doesn't exist
 
-print( "Data Frame Results:" )
-print( dataFrame )
+print( "Post Data Frame Results:" )
+print( postDataFrame )
+
+# ----------------
+# Del Data Sorting
+# ----------------
+
+print( "Sorting data for Del." )
+avgs <- c( fileData[ 'deltoconfrm' ],
+           fileData[ 'elapsedel' ] )
+
+# ------------------------
+# Del Construct Data Frame
+# ------------------------
+
+delDataFrame <- melt( avgs )
+delDataFrame$scale <- fileData$scale
+delDataFrame$date <- fileData$date
+delDataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) )
+
+colnames( delDataFrame ) <- c( "ms",
+                               "type",
+                               "scale",
+                               "date",
+                               "iterative" )
+
+# Format data frame so that the data is in the same order as it appeared in the file.
+delDataFrame$type <- as.character( delDataFrame$type )
+delDataFrame$type <- factor( delDataFrame$type,
+                             levels = unique( delDataFrame$type ) )
+
+delDataFrame <- na.omit( delDataFrame )   # Omit any data that doesn't exist
+
+print( "Del Data Frame Results:" )
+print( delDataFrame )
 
 # **********************************************************
 # STEP 3: Generate graphs.
 # **********************************************************
 
-print( "Generating fundamental graph data." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
+
+# ------------------------------------------
+# Initializing variables used in both graphs
+# ------------------------------------------
+
+print( "Initializing variables used in both graphs." )
 
 theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-
-mainPlot <- ggplot( data = dataFrame, aes( x = iterative, y = ms, fill = type ) )
-xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative, label = dataFrame$date )
 xLabel <- xlab( "Build Date" )
 yLabel <- ylab( "Latency (ms)" )
 fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
 colors <- scale_fill_manual( values=c( "#F77670", "#619DFA" ) )
 wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme
+barWidth <- 0.3
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face = 'bold' ),
+                legend.position = "bottom",
+                legend.text = element_text( size = 22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
+
+barGraphFormat <- geom_bar( stat = "identity",
+                            width = barWidth )
+
+# -----------------------
+# Post Generate Main Plot
+# -----------------------
+
+print( "Creating main plot for Post graph." )
+
+mainPlot <- ggplot( data = postDataFrame, aes( x = iterative,
+                                               y = ms,
+                                               fill = type ) )
+
+# -----------------------------------
+# Post Fundamental Variables Assigned
+# -----------------------------------
+
+print( "Generating fundamental graph data for Post graph." )
+
+xScaleConfig <- scale_x_continuous( breaks = postDataFrame$iterative,
+                                    label = postDataFrame$date )
+title <- ggtitle( postChartTitle )
 
 
-print( "Generating bar graph." )
-width <- 0.3
-barGraphFormat <- geom_bar( stat="identity", width = width )
-sum <- fileData[ 'posttoconfrm' ] + fileData[ 'elapsepost' ]
-values <- geom_text( aes( x=dataFrame$iterative, y=sum + 0.03 * max( sum ), label = format( sum, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-title <- ggtitle( chartTitle )
-result <- fundamentalGraphData + barGraphFormat + colors + title + values
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        wrapLegend +
+                        colors +
+                        title
 
+# --------------------------------
+# Post Generating Bar Graph Format
+# --------------------------------
 
-print( paste( "Saving bar chart to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
+print( "Generating bar graph for Post graph." )
 
-print( paste( "Successfully wrote stacked bar chart out to", errBarOutputFile ) )
+sum <- fileData[ 'posttoconfrm' ] +
+       fileData[ 'elapsepost' ]
 
+values <- geom_text( aes( x = postDataFrame$iterative,
+                          y = sum + 0.03 * max( sum ),
+                          label = format( sum,
+                                          digits = 3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
 
-# **********************************************************
-# STEP 2: Organize data.
-# **********************************************************
+result <- fundamentalGraphData +
+          barGraphFormat +
+          values
 
-avgs <- c()
+# ----------------------------
+# Post Exporting Graph to File
+# ----------------------------
 
-print( "Sorting data." )
-avgs <- c( fileData[ 'deltoconfrm' ], fileData[ 'elapsedel' ] )
+print( paste( "Saving Post bar chart to", postOutputFile ) )
 
-dataFrame <- melt( avgs )
-dataFrame$scale <- fileData$scale
-dataFrame$date <- fileData$date
-dataFrame$iterative <- dataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) )
+ggsave( postOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
 
-colnames( dataFrame ) <- c( "ms", "type", "scale", "date", "iterative" )
+print( paste( "[SUCCESS] Successfully wrote stacked bar chart out to", postOutputFile ) )
 
-# Format data frame so that the data is in the same order as it appeared in the file.
-dataFrame$type <- as.character( dataFrame$type )
-dataFrame$type <- factor( dataFrame$type, levels=unique( dataFrame$type ) )
+# ----------------------
+# Del Generate Main Plot
+# ----------------------
 
-dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
+print( "Creating main plot for Del graph." )
 
-print( "Data Frame Results:" )
-print( dataFrame )
+mainPlot <- ggplot( data = delDataFrame, aes( x = iterative,
+                                              y = ms,
+                                              fill = type ) )
 
-# **********************************************************
-# STEP 3: Generate graphs.
-# **********************************************************
+# ----------------------------------
+# Del Fundamental Variables Assigned
+# ----------------------------------
 
-print( "Generating fundamental graph data." )
+print( "Generating fundamental graph data for Del graph." )
 
-theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
+xScaleConfig <- scale_x_continuous( breaks = delDataFrame$iterative,
+                                    label = delDataFrame$date )
+title <- ggtitle( delChartTitle )
 
-mainPlot <- ggplot( data = dataFrame, aes( x = iterative, y = ms, fill = type ) )
-xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative, label = dataFrame$date )
-xLabel <- xlab( "Build Date" )
-yLabel <- ylab( "Latency (ms)" )
-fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
-colors <- scale_fill_manual( values=c( "#F77670", "#619DFA" ) )
-wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme + wrapLegend
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        wrapLegend +
+                        colors +
+                        title
 
+# -------------------------------
+# Del Generating Bar Graph Format
+# -------------------------------
 
-print( "Generating bar graph." )
-width <- 0.3
-barGraphFormat <- geom_bar( stat="identity", width = width )
-sum <- fileData[ 'deltoconfrm' ] + fileData[ 'elapsedel' ]
-values <- geom_text( aes( x=dataFrame$iterative, y=sum + 0.03 * max( sum ), label = format( sum, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-chartTitle <- paste( "Single Bench Flow Latency - Del", "Last 3 Builds", sep = "\n" )
-title <- ggtitle( chartTitle )
-result <- fundamentalGraphData + barGraphFormat + colors + title + values
+print( "Generating bar graph for Del graph." )
 
-errBarOutputFile <- paste( args[ 7 ], args[ 5 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 6 ], sep="_" )
-errBarOutputFile <- paste( errBarOutputFile, "_DelGraph.jpg", sep="" )
+sum <- fileData[ 'deltoconfrm' ] +
+       fileData[ 'elapsedel' ]
 
-print( paste( "Saving bar chart to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
+values <- geom_text( aes( x = delDataFrame$iterative,
+                          y = sum + 0.03 * max( sum ),
+                          label = format( sum,
+                                          digits = 3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
 
-print( paste( "Successfully wrote stacked bar chart out to", errBarOutputFile ) )
\ No newline at end of file
+result <- fundamentalGraphData +
+          barGraphFormat +
+          title +
+          values
+
+# ---------------------------
+# Del Exporting Graph to File
+# ---------------------------
+
+print( paste( "Saving Del bar chart to", delOutputFile ) )
+
+ggsave( delOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote stacked bar chart out to", delOutputFile ) )
\ No newline at end of file
diff --git a/TestON/JenkinsFile/scripts/SCPFcbench.R b/TestON/JenkinsFile/scripts/SCPFcbench.R
index 55e3978..fa59c55 100644
--- a/TestON/JenkinsFile/scripts/SCPFcbench.R
+++ b/TestON/JenkinsFile/scripts/SCPFcbench.R
@@ -21,66 +21,123 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Normal usage
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 7 ] ) ){
-    print( "Usage: Rscript SCPFcbench <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFcbench",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-errBarOutputFile <- paste( args[ 7 ], args[ 5 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 6 ], sep="_" )
-errBarOutputFile <- paste( errBarOutputFile, "_errGraph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-print( "Reading from databases." )
+print( "Creating filenames and title of graph." )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
-
-command <- paste( "SELECT * FROM cbench_bm_tests WHERE branch='", args[ 6 ], sep="" )
-command <- paste( command, "' ORDER BY date DESC LIMIT 3", sep="" )
-
-print( paste( "Sending SQL command:", command ) )
-
-fileData <- dbGetQuery( con, command )
+errBarOutputFile <- paste( args[ 7 ],
+                           args[ 5 ],
+                           "_",
+                           args[ 6 ],
+                           "_errGraph.jpg",
+                           sep="" )
 
 chartTitle <- paste( "Single-Node CBench Throughput", "Last 3 Builds", sep = "\n" )
 
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# ------------------
+# Cbench SQL Command
+# ------------------
+
+print( "Generating Scale Topology SQL Command" )
+
+command <- paste( "SELECT * FROM cbench_bm_tests WHERE branch='",
+                  args[ 6 ],
+                  "' ORDER BY date DESC LIMIT 3",
+                  sep="" )
+
+print( "Sending SQL command:" )
+print( command )
+
+fileData <- dbGetQuery( con, command )
+
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-fileDataNames <- names( fileData )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-avgs <- c()
-stds <- c()
+# ------------
+# Data Sorting
+# ------------
 
 print( "Sorting data." )
+
 avgs <- c( fileData[ 'avg' ] )
 
+# --------------------
+# Construct Data Frame
+# --------------------
+
+print( "Constructing Data Frame" )
+
 dataFrame <- melt( avgs )
 dataFrame$std <- c( fileData$std )
 dataFrame$date <- c( fileData$date )
 dataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) )
 
-colnames( dataFrame ) <- c( "ms", "type", "std", "date", "iterative" )
+colnames( dataFrame ) <- c( "ms",
+                            "type",
+                            "std",
+                            "date",
+                            "iterative" )
 
 dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
 
@@ -91,29 +148,91 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
+
+# ------------------
+# Generate Main Plot
+# ------------------
+
+print( "Creating main plot." )
+
+mainPlot <- ggplot( data = dataFrame, aes( x = iterative,
+                                           y = ms,
+                                           ymin = ms,
+                                           ymax = ms + std ) )
+
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
+
 print( "Generating fundamental graph data." )
 
 theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-
-mainPlot <- ggplot( data = dataFrame, aes( x = iterative, y = ms, ymin = ms, ymax = ms + std ) )
-xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative, label = dataFrame$date )
+barWidth <- 0.3
+xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative,
+                                    label = dataFrame$date )
 xLabel <- xlab( "Build Date" )
 yLabel <- ylab( "Responses / sec" )
-fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=18, face="bold" ), legend.title = element_blank() )
+fillLabel <- labs( fill = "Type" )
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+errorBarColor <- rgb( 140,140,140, maxColorValue=255 )
 
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face = 'bold' ),
+                legend.position = "bottom",
+                legend.text = element_text( size = 18, face = "bold" ),
+                legend.title = element_blank() )
 
+title <- ggtitle( chartTitle )
+
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        title
+
+# ---------------------------
+# Generating Bar Graph Format
+# ---------------------------
 
 print( "Generating bar graph with error bars." )
-width <- 0.3
-barGraphFormat <- geom_bar( stat="identity", position = position_dodge(), width = width, fill="#00AA13" )
-errorBarFormat <- geom_errorbar( width = width, color=rgb( 140,140,140, maxColorValue=255 ) )
-values <- geom_text( aes( x=dataFrame$iterative, y=fileData[ 'avg' ] + 0.025 * max( fileData[ 'avg' ] ), label = format( fileData[ 'avg' ], digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-title <- ggtitle( chartTitle )
-result <- fundamentalGraphData + barGraphFormat + errorBarFormat + title + values
 
+barGraphFormat <- geom_bar( stat = "identity",
+                            position = position_dodge(),
+                            width = barWidth,
+                            fill = "#00AA13" )
+
+errorBarFormat <- geom_errorbar( width = barWidth,
+                                 color = errorBarColor )
+
+values <- geom_text( aes( x=dataFrame$iterative,
+                          y=fileData[ 'avg' ] + 0.025 * max( fileData[ 'avg' ] ),
+                          label = format( fileData[ 'avg' ],
+                                          digits=3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          errorBarFormat +
+          values
+
+# -----------------------
+# Exporting Graph to File
+# -----------------------
 
 print( paste( "Saving bar chart with error bars to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
-print( paste( "Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
+
+ggsave( errBarOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFflowTp1g.R b/TestON/JenkinsFile/scripts/SCPFflowTp1g.R
index 26584ad..9c79ac8 100644
--- a/TestON/JenkinsFile/scripts/SCPFflowTp1g.R
+++ b/TestON/JenkinsFile/scripts/SCPFflowTp1g.R
@@ -21,89 +21,158 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Normal usage
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 9 ] ) ){
-    print( "Usage: Rscript SCPFflowTp1g.R <has-flow-obj> <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <has-neighbors> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFflowTp1g.R",
+                                  "<has-flow-obj>",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<has-neighbors>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-errBarOutputFile <- paste( args[ 9 ], args[ 6 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 7 ], sep="_" )
-if ( args[ 8 ] == 'y' ){
-    errBarOutputFile <- paste( errBarOutputFile, "all-neighbors", sep="_" )
-} else {
-    errBarOutputFile <- paste( errBarOutputFile, "no-neighbors", sep="_" )
-}
-if ( args[ 1 ] == 'y' ){
-    errBarOutputFile <- paste( errBarOutputFile, "flowObj", sep="_")
-}
-errBarOutputFile <- paste( errBarOutputFile, "_graph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-print( "Reading from databases." )
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 2 ], port=strtoi( args[ 3 ] ), user=args[ 4 ],password=args[ 5 ] )
+print( "Creating filenames and title of graph." )
 
+chartTitle <- "Flow Throughput Test"
+fileNeighborsModifier <- "no"
 commandNeighborModifier <- ""
-flowObjModifier <- ""
+fileFlowObjModifier <- ""
+sqlFlowObjModifier <- ""
 if ( args[ 1 ] == 'y' ){
-    flowObjModifier <- "_fobj"
+    fileFlowObjModifier <- "_flowObj"
+    sqlFlowObjModifier <- "_fobj"
+    chartTitle <- paste( chartTitle, " with Flow Objectives", sep="" )
 }
+
+chartTitle <- paste( chartTitle, "\nNeighbors =", sep="" )
+
 if ( args[ 8 ] == 'y' ){
+    fileNeighborsModifier <- "all"
     commandNeighborModifier <- "scale=1 OR NOT "
+    chartTitle <- paste( chartTitle, "Cluster Size - 1" )
+} else {
+    chartTitle <- paste( chartTitle, "0" )
 }
 
-command <- paste( "SELECT scale, avg( avg ), avg( std ) FROM flow_tp", flowObjModifier, sep="" )
-command <- paste( command, "_tests WHERE (", sep="" )
-command <- paste( command, commandNeighborModifier, sep="" )
-command <- paste( command, "neighbors = 0 ) AND branch = '", sep="" )
-command <- paste( command, args[ 7 ], sep="" )
-command <- paste( command, "' AND date IN ( SELECT max( date ) FROM flow_tp", sep="" )
-command <- paste( command, flowObjModifier, sep="" )
-command <- paste( command, "_tests WHERE branch='", sep="" )
-command <- paste( command, args[ 7 ], sep="" )
-command <- paste( command,  "' ) GROUP BY scale ORDER BY scale", sep="" )
+errBarOutputFile <- paste( args[ 9 ],
+                           args[ 6 ],
+                           "_",
+                           args[ 7 ],
+                           "_",
+                           fileNeighborsModifier,
+                           "-neighbors",
+                           fileFlowObjModifier,
+                           "_graph.jpg",
+                           sep="" )
+# ------------------
+# SQL Initialization
+# ------------------
 
-print( paste( "Sending SQL command:", command ) )
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 2 ],
+                  port = strtoi( args[ 3 ] ),
+                  user = args[ 4 ],
+                  password = args[ 5 ] )
+
+# ---------------------------
+# Flow Throughput SQL Command
+# ---------------------------
+
+print( "Generating Flow Throughput SQL command." )
+
+command <- paste( "SELECT scale, avg( avg ), avg( std ) FROM flow_tp",
+                  sqlFlowObjModifier,
+                  "_tests WHERE (",
+                  commandNeighborModifier,
+                  "neighbors = 0 ) AND branch = '",
+                  args[ 7 ],
+                  "' AND date IN ( SELECT max( date ) FROM flow_tp",
+                  sqlFlowObjModifier,
+                  "_tests WHERE branch='",
+                  args[ 7 ],
+                  "' ) GROUP BY scale ORDER BY scale",
+                  sep="" )
+
+print( "Sending SQL command:" )
+print( command )
 
 fileData <- dbGetQuery( con, command )
 
-title <- paste( args[ 6 ], args[ 7 ], sep="_" )
-
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "STEP 2: Organize data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-# Create lists c() and organize data into their corresponding list.
-print( "Sorting data." )
-colnames( fileData ) <- c( "scale", "avg", "std" )
+# ------------
+# Data Sorting
+# ------------
+
+print( "Sorting data for Flow Throughput." )
+
+colnames( fileData ) <- c( "scale",
+                           "avg",
+                           "std" )
+
 avgs <- c( fileData[ 'avg' ] )
 
-# Parse lists into data frames.
+
+# ----------------------------
+# Flow TP Construct Data Frame
+# ----------------------------
+
+print( "Constructing Flow TP data frame." )
+
 dataFrame <- melt( avgs )              # This is where reshape2 comes in. Avgs list is converted to data frame
-dataFrame$scale <- fileData$scale          # Add node scaling to the data frame.
+dataFrame$scale <- fileData$scale      # Add node scaling to the data frame.
 dataFrame$std <- fileData$std
 
-colnames( dataFrame ) <- c( "throughput", "type", "scale", "std" )
+colnames( dataFrame ) <- c( "throughput",
+                            "type",
+                            "scale",
+                            "std" )
 
 dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
 
@@ -114,19 +183,15 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
-print( "STEP 3: Generate graphs." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
 
-# 1. Graph fundamental data is generated first.
-#    These are variables that apply to all of the graphs being generated, regardless of type.
-#
-# 2. Type specific graph data is generated.
-#     Data specific for the error bar and stacked bar graphs are generated.
-#
-# 3. Generate and save the graphs.
-#      Graphs are saved to the filename above, in the directory provided in command line args
+# ------------------
+# Generate Main Plot
+# ------------------
 
-print( "Generating fundamental graph data." )
-
+print( "Generating main plot." )
 # Create the primary plot here.
 # ggplot contains the following arguments:
 #     - data: the data frame that the graph will be based off of
@@ -135,33 +200,47 @@
 #        - y: y-axis values (usually time in milliseconds)
 #        - fill: the category of the colored side-by-side bars (usually type)
 
-theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
+mainPlot <- ggplot( data = dataFrame, aes( x = scale,
+                                           y = throughput,
+                                           ymin = throughput,
+                                           ymax = throughput + std,
+                                           fill = type ) )
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
 
-mainPlot <- ggplot( data = dataFrame, aes( x = scale, y = throughput, ymin = throughput, ymax = throughput + std, fill = type ) )
+print( "Generating fundamental graph data." )
 
 # Formatting the plot
+theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
 width <- 0.7  # Width of the bars.
-xScaleConfig <- scale_x_continuous( breaks = dataFrame$scale, label = dataFrame$scale )
+xScaleConfig <- scale_x_continuous( breaks = dataFrame$scale,
+                                    label = dataFrame$scale )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Throughput (,000 Flows/sec)" )
 fillLabel <- labs( fill="Type" )
-chartTitle <- "Flow Throughput Test"
-if ( args[ 1 ] == 'y' ){
-    chartTitle <- paste( chartTitle, " with Flow Objectives", sep="" )
-}
-chartTitle <- paste( chartTitle, "\nNeighbors =", sep="" )
-if ( args[ 8 ] == 'y' ){
-    chartTitle <- paste( chartTitle, "Cluster Size - 1" )
-} else {
-    chartTitle <- paste( chartTitle, "0" )
-}
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+errorBarColor <- rgb( 140, 140, 140, maxColorValue=255 )
 
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ) )
-
+theme <- theme( plot.title = element_text( hjust = 0.5,
+                                           size = 32,
+                                           face = 'bold' ) )
+title <- ggtitle( chartTitle )
 
 # Store plot configurations as 1 variable
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        title
 
+# ---------------------------
+# Generating Bar Graph Format
+# ---------------------------
 
 # Create the stacked bar graph with error bars.
 # geom_bar contains:
@@ -169,13 +248,37 @@
 #    - width: the width of the bar types (declared above)
 # geom_errorbar contains similar arguments as geom_bar.
 print( "Generating bar graph with error bars." )
-barGraphFormat <- geom_bar( stat = "identity", width = width, fill="#FFAA3C" )
-errorBarFormat <- geom_errorbar( width = width, position=position_dodge(), color=rgb( 140,140,140, maxColorValue=255 ) )
-values <- geom_text( aes( x=dataFrame$scale, y=dataFrame$throughput + 0.03 * max( dataFrame$throughput ), label = format( dataFrame$throughput, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-title <- ggtitle( paste( chartTitle, "" ) )
-result <- fundamentalGraphData + barGraphFormat + errorBarFormat + title + values
+barGraphFormat <- geom_bar( stat = "identity",
+                            width = width,
+                            fill = "#FFAA3C" )
 
-# Save graph to file
+errorBarFormat <- geom_errorbar( width = width,
+                                 position = position_dodge(),
+                                 color = errorBarColor )
+
+values <- geom_text( aes( x = dataFrame$scale,
+                          y = dataFrame$throughput + 0.03 * max( dataFrame$throughput ),
+                          label = format( dataFrame$throughput,
+                                          digits=3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          errorBarFormat +
+          values
+
+# -----------------------
+# Exporting Graph to File
+# -----------------------
+
 print( paste( "Saving bar chart with error bars to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
-print( paste( "Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
+
+ggsave( errBarOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFhostLat.R b/TestON/JenkinsFile/scripts/SCPFhostLat.R
index f60fc59..0ae64cf 100644
--- a/TestON/JenkinsFile/scripts/SCPFhostLat.R
+++ b/TestON/JenkinsFile/scripts/SCPFhostLat.R
@@ -21,67 +21,123 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
+# -------------------
+# Check CLI Arguments
+# -------------------
 
-# Check if sufficient args are provided.
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 7 ] ) ){
-    print( "Usage: Rscript SCPFhostLat <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFhostLat",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings
-errBarOutputFile <- paste( args[ 7 ], args[ 5 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 6 ], sep="_" )
-errBarOutputFile <- paste( errBarOutputFile, "_errGraph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-print( "Reading from databases." )
+print( "Creating filenames and title of graph." )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
-
-command  <- paste( "SELECT * FROM host_latency_tests WHERE branch = '", args[ 6 ], sep = "" )
-command <- paste( command, "' AND date IN ( SELECT MAX( date ) FROM host_latency_tests WHERE branch = '", sep = "" )
-command <- paste( command, args[ 6 ], sep = "" )
-command <- paste( command, "' ) ", sep="" )
-
-print( paste( "Sending SQL command:", command ) )
-
-fileData <- dbGetQuery( con, command )
+errBarOutputFile <- paste( args[ 7 ],
+                           args[ 5 ],
+                           "_",
+                           args[ 6 ],
+                           "_errGraph.jpg",
+                           sep="" )
 
 chartTitle <- "Host Latency"
 
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# ------------------------
+# Host Latency SQL Command
+# ------------------------
+
+print( "Generating Host Latency SQL Command" )
+
+command  <- paste( "SELECT * FROM host_latency_tests WHERE branch = '",
+                   args[ 6 ],
+                   "' AND date IN ( SELECT MAX( date ) FROM host_latency_tests WHERE branch = '",
+                   args[ 6 ],
+                   "' ) ",
+                   sep = "" )
+
+print( "Sending SQL command:" )
+print( command )
+
+fileData <- dbGetQuery( con, command )
+
 
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "STEP 2: Organize data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-avgs <- c()
+# ------------
+# Data Sorting
+# ------------
 
 print( "Sorting data." )
 avgs <- c( fileData[ 'avg' ] )
 
+# --------------------
+# Construct Data Frame
+# --------------------
+
+print( "Constructing Data Frame" )
+
 dataFrame <- melt( avgs )
 dataFrame$scale <- fileData$scale
 dataFrame$std <- fileData$std
 
-colnames( dataFrame ) <- c( "ms", "type", "scale", "std" )
+colnames( dataFrame ) <- c( "ms",
+                            "type",
+                            "scale",
+                            "std" )
 
 dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
 
@@ -92,29 +148,86 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
+
+# ------------------
+# Generate Main Plot
+# ------------------
+
+print( "Creating main plot." )
+
+mainPlot <- ggplot( data = dataFrame, aes( x = scale,
+                                           y = ms,
+                                           ymin = ms,
+                                           ymax = ms + std ) )
+
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
+
 print( "Generating fundamental graph data." )
 
 theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-mainPlot <- ggplot( data = dataFrame, aes( x = scale, y = ms, ymin = ms, ymax = ms + std ) )
-xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9) )
+xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9 ) )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Latency (ms)" )
 fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ) )
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face ='bold' ) )
+title <- ggtitle( chartTitle )
+errorBarColor <- rgb( 140, 140, 140, maxColorValue = 255 )
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
 
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        title
 
+# ---------------------------
+# Generating Bar Graph Format
+# ---------------------------
 
 print( "Generating bar graph with error bars." )
-width <- 0.9
-barGraphFormat <- geom_bar( stat="identity", position=position_dodge( ), width = width, fill="#A700EF" )
-errorBarFormat <- geom_errorbar( position=position_dodge(), width = width, color=rgb( 140, 140, 140, maxColorValue=255 ) )
-values <- geom_text( aes( x=dataFrame$scale, y=dataFrame$ms + 0.06 * max( dataFrame$ms ), label = format( dataFrame$ms, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-title <- ggtitle( paste( chartTitle, "" ) )
-result <- fundamentalGraphData + barGraphFormat + errorBarFormat + title + values
 
+barWidth <- 0.9
+barGraphFormat <- geom_bar( stat = "identity",
+                            position = position_dodge(),
+                            width = barWidth,
+                            fill = "#A700EF" )
+
+errorBarFormat <- geom_errorbar( position = position_dodge(),
+                                 width = barWidth,
+                                 color = errorBarColor )
+
+values <- geom_text( aes( x=dataFrame$scale,
+                          y=dataFrame$ms + 0.06 * max( dataFrame$ms ),
+                          label = format( dataFrame$ms,
+                                          digits=3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          errorBarFormat +
+          values
+
+# -----------------------
+# Exporting Graph to File
+# -----------------------
 
 print( paste( "Saving bar chart with error bars to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
 
-print( paste( "Successfully wrote bar chart out to", errBarOutputFile ) )
\ No newline at end of file
+ggsave( errBarOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote bar chart out to", errBarOutputFile ) )
\ No newline at end of file
diff --git a/TestON/JenkinsFile/scripts/SCPFintentEventTp.R b/TestON/JenkinsFile/scripts/SCPFintentEventTp.R
index 471fc7a..53fe2d4 100644
--- a/TestON/JenkinsFile/scripts/SCPFintentEventTp.R
+++ b/TestON/JenkinsFile/scripts/SCPFintentEventTp.R
@@ -21,88 +21,151 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
-# Command line arguments are read. Args usually include the database filename and the output
-# directory for the graphs to save to.
+# Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Normal usage
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 9 ] ) ){
-    print( "Usage: Rscript SCPFIntentEventTp.R <has-flow-obj> <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <has-neighbors> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFIntentEventTp.R",
+                                  "<has-flow-obj>",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<has-neighbors>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-errBarOutputFile <- paste( args[ 9 ], args[ 6 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 7 ], sep="_" )
-if ( args[ 8 ] == 'y' ){
-    errBarOutputFile <- paste( errBarOutputFile, "all-neighbors", sep="_" )
-} else {
-    errBarOutputFile <- paste( errBarOutputFile, "no-neighbors", sep="_" )
-}
-if ( args[ 1 ] == 'y' ){
-    errBarOutputFile <- paste( errBarOutputFile, "flowObj", sep="_")
-}
-errBarOutputFile <- paste( errBarOutputFile, "_graph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-print( "Reading from databases." )
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 2 ], port=strtoi( args[ 3 ] ), user=args[ 4 ],password=args[ 5 ] )
+print( "Creating filenames and title of graph." )
 
+chartTitle <- "Intent Event Throughput"
+fileNeighborsModifier <- "no"
 commandNeighborModifier <- ""
-flowObjModifier <- ""
+fileFlowObjModifier <- ""
+sqlFlowObjModifier <- ""
+
 if ( args[ 1 ] == 'y' ){
-    flowObjModifier <- "_fobj"
+    fileFlowObjModifier <- "_flowObj"
+    sqlFlowObjModifier <- "_fobj"
+    chartTitle <- paste( chartTitle, " with Flow Objectives", sep="" )
 }
+
+chartTitle <- paste( chartTitle, "\nevents/second with Neighbors =", sep="" )
+
 if ( args[ 8 ] == 'y' ){
+    fileNeighborsModifier <- "all"
     commandNeighborModifier <- "scale=1 OR NOT "
+    chartTitle <- paste( chartTitle, "all" )
+} else {
+    chartTitle <- paste( chartTitle, "0" )
 }
 
-command <- paste( "SELECT scale, SUM( avg ) as avg FROM intent_tp", flowObjModifier, sep="" )
-command <- paste( command, "_tests WHERE (", sep="" )
-command <- paste( command, commandNeighborModifier, sep="" )
-command <- paste( command, "neighbors = 0 ) AND branch = '", sep="")
-command <- paste( command, args[ 7 ], sep="" )
-command <- paste( command, "' AND date IN ( SELECT max( date ) FROM intent_tp", sep="" )
-command <- paste( command, flowObjModifier, sep="" )
-command <- paste( command, "_tests WHERE branch='", sep="" )
-command <- paste( command, args[ 7 ], sep="" )
-command <- paste( command,  "' ) GROUP BY scale ORDER BY scale", sep="" )
+errBarOutputFile <- paste( args[ 9 ],
+                           args[ 6 ],
+                           "_",
+                           args[ 7 ],
+                           "_",
+                           fileNeighborsModifier,
+                           "-neighbors",
+                           fileFlowObjModifier,
+                           "_graph.jpg",
+                           sep="" )
 
-print( paste( "Sending SQL command:", command ) )
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 2 ],
+                  port = strtoi( args[ 3 ] ),
+                  user = args[ 4 ],
+                  password = args[ 5 ] )
+
+# -----------------------------------
+# Intent Event Throughput SQL Command
+# -----------------------------------
+
+print( "Generating Intent Event Throughput SQL command." )
+
+command <- paste( "SELECT scale, SUM( avg ) as avg FROM intent_tp",
+                  sqlFlowObjModifier,
+                  "_tests WHERE (",
+                  commandNeighborModifier,
+                  "neighbors = 0 ) AND branch = '",
+                  args[ 7 ],
+                  "' AND date IN ( SELECT max( date ) FROM intent_tp",
+                  sqlFlowObjModifier,
+                  "_tests WHERE branch='",
+                  args[ 7 ],
+                  "' ) GROUP BY scale ORDER BY scale",
+                  sep="" )
+
+print( "Sending SQL command:" )
+print( command )
 
 fileData <- dbGetQuery( con, command )
 
-title <- paste( args[ 6 ], args[ 7 ], sep="_" )
-
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "STEP 2: Organize data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-# Create lists c() and organize data into their corresponding list.
+# ------------
+# Data Sorting
+# ------------
+
 print( "Sorting data." )
 avgs <- c( fileData[ 'avg' ] )
 
-# Parse lists into data frames.
+# --------------------
+# Construct Data Frame
+# --------------------
+
+print( "Constructing data frame." )
 dataFrame <- melt( avgs )              # This is where reshape2 comes in. Avgs list is converted to data frame
 dataFrame$scale <- fileData$scale          # Add node scaling to the data frame.
 
-colnames( dataFrame ) <- c( "throughput", "type", "scale" )
+colnames( dataFrame ) <- c( "throughput",
+                            "type",
+                            "scale" )
 
 dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
 
@@ -114,18 +177,15 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
-print( "STEP 3: Generate graphs." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
 
-# 1. Graph fundamental data is generated first.
-#    These are variables that apply to all of the graphs being generated, regardless of type.
-#
-# 2. Type specific graph data is generated.
-#
-# 3. Generate and save the graphs.
-#      Graphs are saved to the filename above, in the directory provided in command line args
+# ------------------
+# Generate Main Plot
+# ------------------
 
-print( "Generating fundamental graph data." )
-
+print( "Generating main plot." )
 # Create the primary plot here.
 # ggplot contains the following arguments:
 #     - data: the data frame that the graph will be based off of
@@ -133,41 +193,74 @@
 #        - x: x-axis values (usually node scaling)
 #        - y: y-axis values (usually time in milliseconds)
 #        - fill: the category of the colored side-by-side bars (usually type)
-theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
 
-mainPlot <- ggplot( data = dataFrame, aes( x = scale, y = throughput, fill = type ) )
+mainPlot <- ggplot( data = dataFrame, aes( x = scale,
+                                           y = throughput,
+                                           fill = type ) )
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
+
+print( "Generating fundamental graph data." )
 
 # Formatting the plot
+theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
 width <- 0.7  # Width of the bars.
 xScaleConfig <- scale_x_continuous( breaks = dataFrame$scale, label = dataFrame$scale )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Throughput (events/second)" )
 fillLabel <- labs( fill="Type" )
-chartTitle <- "Intent Event Throughput"
-if ( args[ 1 ] == 'y' ){
-    chartTitle <- paste( chartTitle, " With Flow Objectives", sep="" )
-}
-chartTitle <- paste( chartTitle, "\nevents/second with Neighbors =", sep="" )
-if ( args[ 8 ] == 'y' ){
-    chartTitle <- paste( chartTitle, "all" )
-} else {
-    chartTitle <- paste( chartTitle, "0" )
-}
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
 
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=18, face="bold" ), legend.title = element_blank() )
-values <- geom_text( aes( x=dataFrame$scale, y=dataFrame$throughput + 0.03 * max( dataFrame$throughput ), label = format( dataFrame$throughput, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7, fontface = "bold" )
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face = 'bold' ),
+                legend.position = "bottom",
+                legend.text = element_text( size = 18, face = "bold" ),
+                legend.title = element_blank() )
+
+values <- geom_text( aes( x = dataFrame$scale,
+                          y = dataFrame$throughput + 0.03 * max( dataFrame$throughput ),
+                          label = format( dataFrame$throughput,
+                                          digits=3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7,
+                          fontface = "bold" )
 
 # Store plot configurations as 1 variable
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme + values
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        values
 
+# ---------------------------
+# Generating Bar Graph Format
+# ---------------------------
 
 print( "Generating bar graph." )
-barGraphFormat <- geom_bar( stat = "identity", width = width, fill="#169EFF" )
-title <- ggtitle( paste( chartTitle, "" ) )
-result <- fundamentalGraphData + barGraphFormat + title
+barGraphFormat <- geom_bar( stat = "identity",
+                            width = width,
+                            fill = "#169EFF" )
 
-# Save graph to file
+title <- ggtitle( chartTitle )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          title
+
+# -----------------------
+# Exporting Graph to File
+# -----------------------
+
 print( paste( "Saving bar chart to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
 
-print( paste( "Successfully wrote bar chart out to", errBarOutputFile ) )
+ggsave( errBarOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote bar chart out to", errBarOutputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFmastershipFailoverLat.R b/TestON/JenkinsFile/scripts/SCPFmastershipFailoverLat.R
index 90bcb8d..82638dc 100644
--- a/TestON/JenkinsFile/scripts/SCPFmastershipFailoverLat.R
+++ b/TestON/JenkinsFile/scripts/SCPFmastershipFailoverLat.R
@@ -21,136 +21,300 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 7 ] ) ){
-    print( "Usage: Rscript SCPFmastershipFailoverLat <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFmastershipFailoverLat",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
         q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-errBarOutputFile <- paste( args[ 7 ], args[ 5 ], sep="" )
-errBarOutputFile <- paste( errBarOutputFile, args[ 6 ], sep="_" )
-errBarOutputFile <- paste( errBarOutputFile, "_errGraph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-stackedBarOutputFile <- paste( args[ 7 ], args[ 5 ], sep="" )
-stackedBarOutputFile <- paste( stackedBarOutputFile, args[ 6 ], sep="_" )
-stackedBarOutputFile <- paste( stackedBarOutputFile, "_stackedGraph.jpg", sep="" )
-
-print( "Reading from databases." )
-
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
-
-command  <- paste( "SELECT * FROM mastership_failover_tests WHERE branch = '", args[ 6 ], sep = "" )
-command <- paste( command, "' AND date IN ( SELECT MAX( date ) FROM mastership_failover_tests WHERE branch = '", sep = "" )
-command <- paste( command, args[ 6 ], sep = "" )
-command <- paste( command, "' ) ", sep="" )
-
-print( paste( "Sending SQL command:", command ) )
-
-fileData <- dbGetQuery( con, command )
+print( "Creating filenames and title of graph." )
 
 chartTitle <- "Mastership Failover Latency"
 
+errBarOutputFile <- paste( args[ 7 ],
+                           args[ 5 ],
+                           "_",
+                           args[ 6 ],
+                           "_errGraph.jpg",
+                           sep="" )
+
+stackedBarOutputFile <- paste( args[ 7 ],
+                        args[ 5 ],
+                        "_",
+                        args[ 6 ],
+                        "_stackedGraph.jpg",
+                        sep="" )
+
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# ---------------------------------------
+# Mastership Failover Latency SQL Command
+# ---------------------------------------
+
+print( "Generating Mastership Failover Latency SQL command" )
+
+command  <- paste( "SELECT * FROM mastership_failover_tests WHERE branch = '",
+                   args[ 6 ],
+                   "' AND date IN ( SELECT MAX( date ) FROM mastership_failover_tests WHERE branch = '",
+                   args[ 6 ],
+                   "' ) ",
+                   sep = "" )
+
+print( "Sending SQL command:" )
+print( command )
+
+fileData <- dbGetQuery( con, command )
 
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-fileDataNames <- names( fileData )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-avgs <- c()
-stds <- c()
+# ------------
+# Data Sorting
+# ------------
 
+print( "Combining averages into a list." )
 
-print( "Sorting data." )
-for ( name in fileDataNames ){
-    nameLen <- nchar( name )
-    if ( nameLen > 2 ){
-        if ( substring( name, nameLen - 2, nameLen ) == "avg" ){
-            avgs <- c( avgs, fileData[ name ] )
-        }
-        if ( substring( name, nameLen - 2, nameLen ) == "std" ){
-            stds <- c( stds, fileData[ name  ] )
-        }
-    }
-}
+avgs <- c( fileData[ 'kill_deact_avg' ],
+           fileData[ 'deact_role_avg' ] )
 
-avgData <- melt( avgs )
-avgData$scale <- fileData$scale
-colnames( avgData ) <- c( "ms", "type", "scale" )
+# --------------------
+# Construct Data Frame
+# --------------------
 
-stdData <- melt( stds )
-colnames( stdData ) <- c( "ms", "type" )
+print( "Constructing Data Frame from list." )
 
-dataFrame <- na.omit( avgData )   # Omit any data that doesn't exist
+dataFrame <- melt( avgs )
+dataFrame$scale <- fileData$scale
+dataFrame$stds <- c( fileData$kill_deact_std,
+                     fileData$deact_role_std )
+
+colnames( dataFrame ) <- c( "ms",
+                            "type",
+                            "scale",
+                            "stds" )
+
+dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
+
+sum <- fileData[ 'deact_role_avg' ] +
+       fileData[ 'kill_deact_avg' ]
 
 print( "Data Frame Results:" )
-print( avgData )
+print( dataFrame )
 
 
 # **********************************************************
 # STEP 3: Generate graphs.
 # **********************************************************
 
-print( "Generating fundamental graph data." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
+
+# ------------------------------------
+# Initialize Variables for Both Graphs
+# ------------------------------------
+
+print( "Initializing variables used in both graphs." )
 
 theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-
-mainPlot <- ggplot( data = avgData, aes( x = scale, y = ms, ymin = ms, ymax = ms + stdData$ms,fill = type ) )
-xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9) )
+xScaleConfig <- scale_x_continuous( breaks = c( 1, 3, 5, 7, 9) )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Latency (ms)" )
-fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
+fillLabel <- labs( fill = "Type" )
+barWidth <- 0.9
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face='bold' ),
+                legend.position = "bottom",
+                legend.text = element_text( size=22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
+
+barColors <- scale_fill_manual( values=c( "#F77670",
+                                       "#619DFA" ) )
+
 wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
 
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme + wrapLegend
+# ----------------------------------
+# Error Bar Graph Generate Main Plot
+# ----------------------------------
 
+print( "Creating main plot." )
+
+mainPlot <- ggplot( data = dataFrame, aes( x = scale,
+                                           y = ms,
+                                           ymin = ms,
+                                           ymax = ms + stds,
+                                           fill = type ) )
+
+# ----------------------------------------------
+# Error Bar Graph Fundamental Variables Assigned
+# ----------------------------------------------
+
+print( "Generating fundamental graph data for the error bar graph." )
+
+errorBarColor <- rgb( 140, 140, 140, maxColorValue=255 )
+
+title <- ggtitle( chartTitle )
+
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        title +
+                        wrapLegend
+
+# -------------------------------------------
+# Error Bar Graph Generating Bar Graph Format
+# -------------------------------------------
 
 print( "Generating bar graph with error bars." )
-width <- 0.9
-barGraphFormat <- geom_bar( stat="identity", position=position_dodge(), width = width )
-colors <- scale_fill_manual( values=c( "#F77670", "#619DFA" ) )
-errorBarFormat <- geom_errorbar( width = width, position=position_dodge(), color=rgb( 140, 140, 140, maxColorValue=255 ) )
-values <- geom_text( aes( x=avgData$scale, y=avgData$ms + 0.02 * max( avgData$ms ), label = format( avgData$ms, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold", position=position_dodge( 0.9 ) )
-title <- ggtitle( paste( chartTitle, "" ) )
-result <- fundamentalGraphData + barGraphFormat + colors + errorBarFormat + title + values
 
+barGraphFormat <- geom_bar( stat = "identity",
+                            position = position_dodge(),
+                            width = barWidth )
+
+errorBarFormat <- geom_errorbar( width = barWidth,
+                                 position = position_dodge(),
+                                 color = errorBarColor )
+
+values <- geom_text( aes( x = dataFrame$scale,
+                          y = dataFrame$ms + 0.02 * max( dataFrame$ms ),
+                          label = format( dataFrame$ms,
+                                          digits = 3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold",
+                          position = position_dodge( 0.9 ) )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          barColors +
+          errorBarFormat +
+          values
+
+# ---------------------------------------
+# Error Bar Graph Exporting Graph to File
+# ---------------------------------------
 
 print( paste( "Saving bar chart with error bars to", errBarOutputFile ) )
-ggsave( errBarOutputFile, width = 15, height = 10, dpi = 200 )
 
+ggsave( errBarOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
 
-print( paste( "Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars out to", errBarOutputFile ) )
 
+# ------------------------------------------------
+# Stacked Bar Graph Fundamental Variables Assigned
+# ------------------------------------------------
+
+print( "Generating fundamental graph data for the stacked bar graph." )
+
+title <- ggtitle( chartTitle )
+
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        title +
+                        wrapLegend
+
+# ---------------------------------------------
+# Stacked Bar Graph Generating Bar Graph Format
+# ---------------------------------------------
 
 print( "Generating stacked bar chart." )
-stackedBarFormat <- geom_bar( stat="identity", width=width )
-title <- ggtitle( paste( chartTitle, "" ) )
-sum <- fileData[ 'deact_role_avg' ] + fileData[ 'kill_deact_avg' ]
-values <- geom_text( aes( x=avgData$scale, y=sum + 0.02 * max( sum ), label = format( sum, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-result <- fundamentalGraphData + stackedBarFormat + colors + title + values
+stackedBarFormat <- geom_bar( stat = "identity",
+                              width = barWidth )
 
+values <- geom_text( aes( x = dataFrame$scale,
+                          y = sum + 0.02 * max( sum ),
+                          label = format( sum,
+                                          digits = 3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
+
+result <- fundamentalGraphData +
+          stackedBarFormat +
+          barColors +
+          title +
+          values
+
+# -----------------------------------------
+# Stacked Bar Graph Exporting Graph to File
+# -----------------------------------------
 
 print( paste( "Saving stacked bar chart to", stackedBarOutputFile ) )
-ggsave( stackedBarOutputFile, width = 15, height = 10, dpi = 200 )
 
+ggsave( stackedBarOutputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
 
-print( paste( "Successfully wrote stacked bar chart out to", stackedBarOutputFile ) )
\ No newline at end of file
+print( paste( "[SUCCESS] Successfully wrote stacked bar chart out to", stackedBarOutputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFportLat.R b/TestON/JenkinsFile/scripts/SCPFportLat.R
index 0f9176a..bb43248 100644
--- a/TestON/JenkinsFile/scripts/SCPFportLat.R
+++ b/TestON/JenkinsFile/scripts/SCPFportLat.R
@@ -21,144 +21,346 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 7 ] ) ){
-    print( "Usage: Rscript SCPFportLat <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFportLat",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-errBarOutputFileUp <- paste( args[ 7 ], "SCPFportLat_", sep = "" )
-errBarOutputFileUp <- paste( errBarOutputFileUp, args[ 6 ], sep = "" )
-errBarOutputFileUp <- paste( errBarOutputFileUp, "_UpErrBarWithStack.jpg", sep = "" )
+# -----------------
+# Create File Names
+# -----------------
 
-errBarOutputFileDown <- paste( args[ 7 ], "SCPFportLat_", sep = "" )
-errBarOutputFileDown <- paste( errBarOutputFileDown, args[ 6 ], sep = "" )
-errBarOutputFileDown <- paste( errBarOutputFileDown, "_DownErrBarWithStack.jpg", sep = "" )
+print( "Creating filenames and title of graph." )
 
-print( "Reading from databases." )
+errBarOutputFileUp <- paste( args[ 7 ],
+                             "SCPFportLat_",
+                             args[ 6 ],
+                             "_UpErrBarWithStack.jpg",
+                             sep = "" )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
+errBarOutputFileDown <- paste( args[ 7 ],
+                             "SCPFportLat_",
+                             args[ 6 ],
+                             "_DownErrBarWithStack.jpg",
+                             sep = "" )
 
-command  <- paste( "SELECT * FROM port_latency_details WHERE branch = '", args[ 6 ], sep = "" )
-command <- paste( command, "' AND date IN ( SELECT MAX( date ) FROM port_latency_details WHERE branch = '", sep = "" )
-command <- paste( command, args[ 6 ], sep = "" )
-command <- paste( command, "' ) ", sep="" )
+# ------------------
+# SQL Initialization
+# ------------------
 
-print( paste( "Sending SQL command:", command ) )
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# ------------------------
+# Port Latency SQL Command
+# ------------------------
+
+print( "Generating Port Latency SQL Command" )
+
+command <- paste( "SELECT * FROM port_latency_details WHERE branch = '",
+                  args[ 6 ],
+                  "' AND date IN ( SELECT MAX( date ) FROM port_latency_details WHERE branch = '",
+                  args[ 6 ],
+                  "' ) ",
+                  sep = "" )
+
+print( "Sending SQL command:" )
+print( command )
 
 fileData <- dbGetQuery( con, command )
 
-chartTitle <- paste( "Port Latency", args[ 6 ], sep = " - " )
-chartTitle <- paste( chartTitle, "\n" )
-
-
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "Sorting data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-upAvgs <- c( fileData[ 'up_ofp_to_dev_avg' ], fileData[ 'up_dev_to_link_avg' ], fileData[ 'up_link_to_graph_avg' ] )
-upAvgsData <- melt( upAvgs )
-upAvgsData$scale <- fileData$scale
-upAvgsData$up_std <- fileData$up_std
+# -----------------------------
+# Port Up Averages Data Sorting
+# -----------------------------
 
+print( "Sorting data for Port Up Averages." )
 
-colnames( upAvgsData ) <- c( "ms", "type", "scale", "stds" )
-upAvgsData$type <- as.character( upAvgsData$type )
-upAvgsData$type <- factor( upAvgsData$type, levels=unique( upAvgsData$type ) )
+upAvgs <- c( fileData[ 'up_ofp_to_dev_avg' ],
+             fileData[ 'up_dev_to_link_avg' ],
+             fileData[ 'up_link_to_graph_avg' ] )
 
-downAvgs <- c( fileData[ 'down_ofp_to_dev_avg' ], fileData[ 'down_dev_to_link_avg' ], fileData[ 'down_link_to_graph_avg' ] )
-downAvgsData <- melt( downAvgs )
-downAvgsData$scale <- fileData$scale
-downAvgsData$down_std <- fileData$down_std
+# ----------------------------
+# Port Up Construct Data Frame
+# ----------------------------
 
-colnames( downAvgsData ) <- c( "ms", "type", "scale", "stds" )
-downAvgsData$type <- as.character( downAvgsData$type )
-downAvgsData$type <- factor( downAvgsData$type, levels=unique( downAvgsData$type ) )
+print( "Constructing Port Up data frame." )
 
-upAvgsData <- na.omit( upAvgsData )   # Omit any data that doesn't exist
-downAvgsData <- na.omit( downAvgsData )   # Omit any data that doesn't exist
+upAvgsDataFrame <- melt( upAvgs )
+upAvgsDataFrame$scale <- fileData$scale
+upAvgsDataFrame$up_std <- fileData$up_std
+
+colnames( upAvgsDataFrame ) <- c( "ms",
+                             "type",
+                             "scale",
+                             "stds" )
+
+upAvgsDataFrame <- na.omit( upAvgsDataFrame )
+
+upAvgsDataFrame$type <- as.character( upAvgsDataFrame$type )
+upAvgsDataFrame$type <- factor( upAvgsDataFrame$type, levels=unique( upAvgsDataFrame$type ) )
+
+sumOfUpAvgs <- fileData[ 'up_ofp_to_dev_avg' ] +
+               fileData[ 'up_dev_to_link_avg' ] +
+               fileData[ 'up_link_to_graph_avg' ]
 
 print( "Up Averages Results:" )
-print( upAvgsData )
+print( upAvgsDataFrame )
+
+# -------------------------------
+# Port Down Averages Data Sorting
+# -------------------------------
+
+print( "Sorting data for Port Down Averages." )
+
+downAvgs <- c( fileData[ 'down_ofp_to_dev_avg' ],
+               fileData[ 'down_dev_to_link_avg' ],
+               fileData[ 'down_link_to_graph_avg' ] )
+
+# ------------------------------
+# Port Down Construct Data Frame
+# ------------------------------
+
+print( "Constructing Port Down data frame." )
+
+downAvgsDataFrame <- melt( downAvgs )
+downAvgsDataFrame$scale <- fileData$scale
+downAvgsDataFrame$down_std <- fileData$down_std
+
+colnames( downAvgsDataFrame ) <- c( "ms",
+                               "type",
+                               "scale",
+                               "stds" )
+
+downAvgsDataFrame <- na.omit( downAvgsDataFrame )
+
+downAvgsDataFrame$type <- as.character( downAvgsDataFrame$type )
+downAvgsDataFrame$type <- factor( downAvgsDataFrame$type, levels=unique( downAvgsDataFrame$type ) )
+
+sumOfDownAvgs <- fileData[ 'down_ofp_to_dev_avg' ] +
+                 fileData[ 'down_dev_to_link_avg' ] +
+                 fileData[ 'down_link_to_graph_avg' ]
 
 print( "Down Averages Results:" )
-print( downAvgsData )
+print( downAvgsDataFrame )
 
 # **********************************************************
 # STEP 3: Generate graphs.
 # **********************************************************
 
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
 
-print( "Generating fundamental graph data (Port Up Latency)." )
-width <- 1
+# ------------------------------------
+# Initialize Variables For Both Graphs
+# ------------------------------------
+
+print( "Initializing variables used in both graphs." )
+
 theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-
-mainPlot <- ggplot( data = upAvgsData, aes( x = scale, y = ms, fill = type, ymin = fileData[ 'up_end_to_end_avg' ], ymax = fileData[ 'up_end_to_end_avg' ] + stds ) )
-xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9) )
+barWidth <- 1
+xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9 ) )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Latency (ms)" )
 fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
-colors <- scale_fill_manual( values=c( "#F77670", "#619DFA", "#18BA48" ) )
 wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+errorBarColor <- rgb( 140, 140, 140, maxColorValue=255 )
 
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme + wrapLegend
+theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ),
+                legend.position="bottom",
+                legend.text=element_text( size=22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
+
+colors <- scale_fill_manual( values=c( "#F77670",
+                                       "#619DFA",
+                                       "#18BA48" ) )
+
+# --------------------------
+# Port Up Generate Main Plot
+# --------------------------
+
+print( "Generating main plot (Port Up Latency)." )
+
+mainPlot <- ggplot( data = upAvgsDataFrame, aes( x = scale,
+                                            y = ms,
+                                            fill = type,
+                                            ymin = fileData[ 'up_end_to_end_avg' ],
+                                            ymax = fileData[ 'up_end_to_end_avg' ] + stds ) )
+
+# --------------------------------------
+# Port Up Fundamental Variables Assigned
+# --------------------------------------
+
+print( "Generating fundamental graph data (Port Up Latency)." )
+
+title <- ggtitle( "Port Up Latency" )
+
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        wrapLegend +
+                        title +
+                        colors
+
+# -----------------------------------
+# Port Up Generating Bar Graph Format
+# -----------------------------------
 
 print( "Generating bar graph with error bars (Port Up Latency)." )
-barGraphFormat <- geom_bar( stat="identity", width = width )
-errorBarFormat <- geom_errorbar( width = width, color=rgb( 140, 140, 140, maxColorValue=255 ) )
-sum <- fileData[ 'up_ofp_to_dev_avg' ] + fileData[ 'up_dev_to_link_avg' ] + fileData[ 'up_link_to_graph_avg' ]
-values <- geom_text( aes( x=upAvgsData$scale, y=sum + 0.03 * max( sum ), label = format( sum, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-title <- ggtitle( "Port Up Latency" )
-result <- fundamentalGraphData + barGraphFormat + colors + errorBarFormat + title + values
 
+barGraphFormat <- geom_bar( stat = "identity",
+                            width = barWidth )
+errorBarFormat <- geom_errorbar( width = barWidth,
+                                 color = errorBarColor )
+
+values <- geom_text( aes( x = upAvgsDataFrame$scale,
+                          y = sumOfUpAvgs + 0.03 * max( sumOfUpAvgs ),
+                          label = format( sumOfUpAvgs,
+                                          digits=3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          errorBarFormat +
+          values
+
+# -------------------------------
+# Port Up Exporting Graph to File
+# -------------------------------
 
 print( paste( "Saving bar chart with error bars (Port Up Latency) to", errBarOutputFileUp ) )
-ggsave( errBarOutputFileUp, width = 15, height = 10, dpi = 200 )
 
+ggsave( errBarOutputFileUp,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
 
-print( paste( "Successfully wrote bar chart with error bars (Port Up Latency) out to", errBarOutputFileUp ) )
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars (Port Up Latency) out to", errBarOutputFileUp ) )
 
+# ----------------------------
+# Port Down Generate Main Plot
+# ----------------------------
+
+print( "Generating main plot (Port Down Latency)." )
+
+mainPlot <- ggplot( data = downAvgsDataFrame, aes( x = scale,
+                                              y = ms,
+                                              fill = type,
+                                              ymin = fileData[ 'down_end_to_end_avg' ],
+                                              ymax = fileData[ 'down_end_to_end_avg' ] + stds ) )
+
+# ----------------------------------------
+# Port Down Fundamental Variables Assigned
+# ----------------------------------------
 
 print( "Generating fundamental graph data (Port Down Latency)." )
 
-mainPlot <- ggplot( data = downAvgsData, aes( x = scale, y = ms, fill = type, ymin = fileData[ 'down_end_to_end_avg' ], ymax = fileData[ 'down_end_to_end_avg' ] + stds ) )
-wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
+title <- ggtitle( "Port Down Latency" )
 
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme + wrapLegend
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        wrapLegend +
+                        title +
+                        colors
+
+# -------------------------------------
+# Port Down Generating Bar Graph Format
+# -------------------------------------
 
 print( "Generating bar graph with error bars (Port Down Latency)." )
-barGraphFormat <- geom_bar( stat="identity", width = width )
-errorBarFormat <- geom_errorbar( width = width, color=rgb( 140, 140, 140, maxColorValue=255 ) )
-sum <- fileData[ 'down_ofp_to_dev_avg' ] + fileData[ 'down_dev_to_link_avg' ] + fileData[ 'down_link_to_graph_avg' ]
-values <- geom_text( aes( x=downAvgsData$scale, y=sum + 0.03 * max( sum ), label = format( sum, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
 
-title <- ggtitle( "Port Down Latency" )
-result <- fundamentalGraphData + barGraphFormat + colors + errorBarFormat + title + values
+barGraphFormat <- geom_bar( stat = "identity",
+                            width = barWidth )
+errorBarFormat <- geom_errorbar( width = barWidth,
+                                 color = errorBarColor )
 
+values <- geom_text( aes( x = downAvgsDataFrame$scale,
+                          y = sumOfDownAvgs + 0.03 * max( sumOfDownAvgs ),
+                          label = format( sumOfDownAvgs,
+                                          digits=3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 7.0,
+                          fontface = "bold" )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          errorBarFormat +
+          values
+
+# ---------------------------------
+# Port Down Exporting Graph to File
+# ---------------------------------
 
 print( paste( "Saving bar chart with error bars (Port Down Latency) to", errBarOutputFileDown ) )
-ggsave( errBarOutputFileDown, width = 15, height = 10, dpi = 200 )
 
+ggsave( errBarOutputFileDown,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
 
-print( paste( "Successfully wrote bar chart with error bars (Port Down Latency) out to", errBarOutputFileDown ) )
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars (Port Down Latency) out to", errBarOutputFileDown ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFscaleTopo.R b/TestON/JenkinsFile/scripts/SCPFscaleTopo.R
index 6be3533..8344efb 100644
--- a/TestON/JenkinsFile/scripts/SCPFscaleTopo.R
+++ b/TestON/JenkinsFile/scripts/SCPFscaleTopo.R
@@ -21,64 +21,121 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 7 ] ) ){
-    print( "Usage: Rscript SCPFgraphGenerator <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFgraphGenerator",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" ") )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings
-outputFile <- paste( args[ 7 ], args[ 5 ], sep="" )
-outputFile <- paste( outputFile, args[ 6 ], sep="_" )
-outputFile <- paste( outputFile, "_graph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-print( "Reading from databases." )
+print( "Creating filenames and title of graph." )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
+outputFile <- paste( args[ 7 ],
+                     args[ 5 ],
+                     "_",
+                     args[ 6 ],
+                     "_graph.jpg",
+                     sep="" )
 
-command  <- paste( "SELECT * FROM scale_topo_latency_details WHERE branch = '", args[ 6 ], sep = "" )
-command <- paste( command, "' AND date IN ( SELECT MAX( date ) FROM scale_topo_latency_details WHERE branch = '", sep = "" )
-command <- paste( command, args[ 6 ], sep = "" )
-command <- paste( command, "' ) ", sep="" )
+chartTitle <- "Scale Topology Latency Test"
 
-print( paste( "Sending SQL command:", command ) )
+# ------------------
+# SQL Initialization
+# ------------------
 
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# --------------------------
+# Scale Topology SQL Command
+# --------------------------
+
+print( "Generating Scale Topology SQL Command" )
+
+command <- paste( "SELECT * FROM scale_topo_latency_details WHERE branch = '",
+                  args[ 6 ],
+                  "' AND date IN ( SELECT MAX( date ) FROM scale_topo_latency_details WHERE branch = '",
+                  args[ 6 ],
+                  "' ) ",
+                  sep = "" )
+
+print( "Sending SQL command:" )
+print( command )
 fileData <- dbGetQuery( con, command )
 
-title <- paste( args[ 5 ], args[ 6 ], sep="_" )
-
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "STEP 2: Organize data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-# Create lists c() and organize data into their corresponding list.
+# ------------
+# Data Sorting
+# ------------
+
 print( "Sorting data." )
-avgs <- c( fileData[ 'last_role_request_to_last_topology' ], fileData[ 'last_connection_to_last_role_request' ], fileData[ 'first_connection_to_last_connection' ] )
+avgs <- c( fileData[ 'last_role_request_to_last_topology' ],
+           fileData[ 'last_connection_to_last_role_request' ],
+           fileData[ 'first_connection_to_last_connection' ] )
+
+# --------------------
+# Construct Data Frame
+# --------------------
+
+print( "Constructing Data Frame" )
 
 # Parse lists into data frames.
-dataFrame <- melt( avgs )              # This is where reshape2 comes in. Avgs list is converted to data frame
-dataFrame$scale <- fileData$scale      # Add node scaling to the data frame.
-colnames( dataFrame ) <- c( "s", "type", "scale")
-
+dataFrame <- melt( avgs )
+dataFrame$scale <- fileData$scale
+colnames( dataFrame ) <- c( "s",
+                            "type",
+                            "scale")
 
 # Format data frame so that the data is in the same order as it appeared in the file.
 dataFrame$type <- as.character( dataFrame$type )
@@ -87,7 +144,9 @@
 
 dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
 
-sum <- fileData[ 'last_role_request_to_last_topology' ] + fileData[ 'last_connection_to_last_role_request' ] + fileData[ 'first_connection_to_last_connection' ]
+sum <- fileData[ 'last_role_request_to_last_topology' ] +
+       fileData[ 'last_connection_to_last_role_request' ] +
+       fileData[ 'first_connection_to_last_connection' ]
 
 print( "Data Frame Results:" )
 print( dataFrame )
@@ -96,48 +155,86 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
-print( "STEP 3: Generate graphs." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
 
-# 1. Graph fundamental data is generated first.
-#    These are variables that apply to all of the graphs being generated, regardless of type.
-#
-# 2. Type specific graph data is generated.
-#
-# 3. Generate and save the graphs.
-#      Graphs are saved to the filename above, in the directory provided in command line args
+# ------------------
+# Generate Main Plot
+# ------------------
+
+print( "Creating main plot." )
+
+mainPlot <- ggplot( data = dataFrame, aes( x = iterative,
+                                           y = s,
+                                           fill = type ) )
+
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
 
 print( "Generating fundamental graph data." )
 
 theme_set( theme_grey( base_size = 20 ) )   # set the default text size of the graph.
-
-# Create the primary plot here.
-# ggplot contains the following arguments:
-#     - data: the data frame that the graph will be based off of
-#     - aes: the asthetics of the graph which require:
-#        - x: x-axis values (usually node scaling)
-#        - y: y-axis values (usually time in milliseconds)
-#        - fill: the category of the colored side-by-side bars (usually type)
-mainPlot <- ggplot( data = dataFrame, aes( x = iterative, y = s, fill = type ) )
-
-# Formatting the plot
 width <- 0.6  # Width of the bars.
-xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative, label = dataFrame$scale )
+xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative,
+                                    label = dataFrame$scale )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Latency (s)" )
 fillLabel <- labs( fill="Type" )
-chartTitle <- paste( "Scale Topology Latency Test" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
-values <- geom_text( aes( x=dataFrame$iterative, y=sum + 0.02 * max( sum ), label = format( sum, big.mark = ",", scientific = FALSE ), fontface = "bold" ), size = 7.0 )
-wrapLegend <- guides( fill=guide_legend( nrow=2, byrow=TRUE ) )
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face = 'bold' ),
+                legend.position = "bottom",
+                legend.text = element_text( size=22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
+
+values <- geom_text( aes( x = dataFrame$iterative,
+                          y = sum + 0.02 * max( sum ),
+                          label = format( sum,
+                                          big.mark = ",",
+                                          scientific = FALSE ),
+                          fontface = "bold" ),
+                          size = 7.0 )
+
+wrapLegend <- guides( fill = guide_legend( nrow=2, byrow=TRUE ) )
+
+title <- ggtitle( chartTitle, "" )
+
 # Store plot configurations as 1 variable
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme + values + wrapLegend
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        values +
+                        wrapLegend +
+                        title
+
+# ---------------------------
+# Generating Bar Graph Format
+# ---------------------------
 
 print( "Generating bar graph." )
-barGraphFormat <- geom_bar( stat = "identity", width = width )
-title <- ggtitle( paste( chartTitle, "" ) )
-result <- fundamentalGraphData + barGraphFormat + title
 
-# Save graph to file
+barGraphFormat <- geom_bar( stat = "identity", width = width )
+
+result <- fundamentalGraphData +
+          barGraphFormat
+
+# -----------------------
+# Exporting Graph to File
+# -----------------------
+
 print( paste( "Saving bar chart to", outputFile ) )
-ggsave( outputFile, width = 15, height = 10, dpi = 200 )
-print( paste( "Successfully wrote bar chart out to", outputFile ) )
+
+ggsave( outputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote bar chart out to", outputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFscalingMaxIntents.R b/TestON/JenkinsFile/scripts/SCPFscalingMaxIntents.R
index 0f09023..2ca0627 100644
--- a/TestON/JenkinsFile/scripts/SCPFscalingMaxIntents.R
+++ b/TestON/JenkinsFile/scripts/SCPFscalingMaxIntents.R
@@ -21,75 +21,127 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Normal usage
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 8 ] ) ){
-    print( "Usage: Rscript SCPFInstalledIntentsFlows <has-flowObj> <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFInstalledIntentsFlows",
+                                  "<has-flowObj>",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",
+                                  "<branch-name>",
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-outputFile <- paste( args[ 8 ], args[ 6 ], sep="" )
-if ( args[ 1 ] == "y" ){
-    outputFile <- paste( outputFile, "flowObj", sep="_" )
-}
-outputFile <- paste( outputFile, args[ 7 ], sep="_" )
-outputFile <- paste( outputFile, "_errGraph.jpg", sep="" )
+# -----------------
+# Create File Names
+# -----------------
 
-print( "Reading from databases." )
+print( "Creating filenames and title of graph." )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 2 ], port=strtoi( args[ 3 ] ), user=args[ 4 ],password=args[ 5 ] )
-
-command  <- "SELECT * FROM max_intents_"
-if ( args[ 1 ] == "y" ){
-    command <- paste( command, "fobj_", sep="" )
-}
-command <- paste( command, "tests WHERE branch = '", sep = "" )
-command <- paste( command, args[ 7 ], sep="" )
-command <- paste( command, "' AND date IN ( SELECT MAX( date ) FROM max_intents_", sep="" )
-if ( args[ 1 ] == "y" ){
-    command <- paste( command, "fobj_", sep="" )
-}
-command <- paste( command, "tests WHERE branch = '", sep = "" )
-command <- paste( command, args[ 7 ], sep = "" )
-command <- paste( command, "' ) ", sep="" )
-
-print( paste( "Sending SQL command:", command ) )
-
-fileData <- dbGetQuery( con, command )
+fileFlowObjModifier <- ""
+sqlFlowObjModifier <- ""
+chartTitle <- "Number of Installed Intents & Flows"
 
 if ( args[ 1 ] == "y" ){
+    fileFlowObjModifier <- "_flowObj"
+    sqlFlowObjModifier <- "fobj_"
     chartTitle <- "Number of Installed Intents & Flows\n with Flow Objectives"
-} else {
-    chartTitle <- "Number of Installed Intents & Flows"
 }
 
+outputFile <- paste( args[ 8 ],
+                     args[ 6 ],
+                     fileFlowObjModifier,
+                     "_",
+                     args[ 7 ],
+                     "_errGraph.jpg",
+                     sep="" )
+
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 2 ],
+                  port = strtoi( args[ 3 ] ),
+                  user = args[ 4 ],
+                  password = args[ 5 ] )
+
+# -------------------------------
+# Scaling Max Intents SQL Command
+# -------------------------------
+
+print( "Scaling Max Intents SQL Command" )
+
+command <- paste( "SELECT * FROM max_intents_",
+                  sqlFlowObjModifier,
+                  "tests WHERE branch = '",
+                  args[ 7 ],
+                  "' AND date IN ( SELECT MAX( date ) FROM max_intents_",
+                  sqlFlowObjModifier,
+                  "tests WHERE branch = '",
+                  args[ 7 ],
+                  "' ) ",
+                  sep="" )
+
+print( "Sending SQL command:" )
+print( command )
+fileData <- dbGetQuery( con, command )
+
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-fileDataNames <- names( fileData )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-avgs <- c()
+# ------------
+# Data Sorting
+# ------------
 
 print( "Sorting data." )
-avgs <- c( fileData[ 'max_intents_ovs' ], fileData[ 'max_flows_ovs' ] )
+
+avgs <- c( fileData[ 'max_intents_ovs' ],
+           fileData[ 'max_flows_ovs' ] )
+
+# --------------------
+# Construct Data Frame
+# --------------------
+
+print( "Constructing Data Frame" )
 
 dataFrame <- melt( avgs )
 dataFrame$scale <- fileData$scale
@@ -108,30 +160,90 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
+
+# ------------------
+# Generate Main Plot
+# ------------------
+
+print( "Creating main plot." )
+mainPlot <- ggplot( data = dataFrame, aes( x = scale,
+                                           y = ms,
+                                           fill = type ) )
+
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
+
 print( "Generating fundamental graph data." )
 
+barWidth <- 1.3
 theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
-
-mainPlot <- ggplot( data = dataFrame, aes( x = scale, y = ms, fill = type ) )
-xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9) )
+xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9 ) )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Max Number of Intents/Flow Rules" )
 fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
-colors <- scale_fill_manual( values=c( "#F77670", "#619DFA" ) )
-wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme + wrapLegend
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
 
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face = 'bold' ),
+                legend.position = "bottom",
+                legend.text = element_text( size=22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
 
-print( "Generating bar graph bars." )
-width <- 1.3
-barGraphFormat <- geom_bar( stat="identity", position=position_dodge( ), width = width )
-values <- geom_text( aes( x=dataFrame$scale, y=dataFrame$ms + 0.015 * max( dataFrame$ms ), label = format( dataFrame$ms, digits=3, big.mark = ",", scientific = FALSE ) ), size = 5.2, fontface = "bold", position=position_dodge( width=1.25 ) )
+colors <- scale_fill_manual( values = c( "#F77670",
+                                         "#619DFA" ) )
+
+wrapLegend <- guides( fill = guide_legend( nrow = 1, byrow = TRUE ) )
 title <- ggtitle( chartTitle )
-result <- fundamentalGraphData + barGraphFormat + colors + title + values
 
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        fillLabel +
+                        theme +
+                        wrapLegend +
+                        title +
+                        colors
+
+# ---------------------------
+# Generating Bar Graph Format
+# ---------------------------
+
+print( "Generating bar graph." )
+
+barGraphFormat <- geom_bar( stat = "identity",
+                            position = position_dodge(),
+                            width = barWidth )
+
+values <- geom_text( aes( x = dataFrame$scale,
+                          y = dataFrame$ms + 0.015 * max( dataFrame$ms ),
+                          label = format( dataFrame$ms,
+                                          digits=3,
+                                          big.mark = ",",
+                                          scientific = FALSE ) ),
+                          size = 5.2,
+                          fontface = "bold",
+                          position = position_dodge( width = 1.25 ) )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          values
+
+# -----------------------
+# Exporting Graph to File
+# -----------------------
 
 print( paste( "Saving bar chart to", outputFile ) )
-ggsave( outputFile, width = 15, height = 10, dpi = 200 )
 
-print( paste( "Successfully wrote bar chart out to", outputFile ) )
+ggsave( outputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote bar chart out to", outputFile ) )
diff --git a/TestON/JenkinsFile/scripts/SCPFswitchLat.R b/TestON/JenkinsFile/scripts/SCPFswitchLat.R
index 7bf0a44..97b8d44 100644
--- a/TestON/JenkinsFile/scripts/SCPFswitchLat.R
+++ b/TestON/JenkinsFile/scripts/SCPFswitchLat.R
@@ -21,48 +21,92 @@
 # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu
 
 # **********************************************************
-# STEP 1: File management.
+# STEP 1: Data management.
 # **********************************************************
 
-print( "STEP 1: File management." )
+print( "**********************************************************" )
+print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )    # For databases
 
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 7 ] ) ){
-    print( "Usage: Rscript SCPFswitchLat <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript SCPFswitchLat",
+                            "<database-host>",
+                            "<database-port>",
+                            "<database-user-id>",
+                            "<database-password>",
+                            "<test-name>",
+                            "<branch-name>",
+                            "<directory-to-save-graphs>",
+                            sep=" ") )
+
     q()  # basically exit(), but in R
 }
 
-# paste() is used to concatenate strings.
-errBarOutputFileUp <- paste( args[ 7 ], "SCPFswitchLat_", sep = "" )
-errBarOutputFileUp <- paste( errBarOutputFileUp, args[ 6 ], sep = "" )
-errBarOutputFileUp <- paste( errBarOutputFileUp, "_UpErrBarWithStack.jpg", sep = "" )
+# -----------------
+# Create File Names
+# -----------------
 
-errBarOutputFileDown <- paste( args[ 7 ], "SCPFswitchLat_", sep = "" )
-errBarOutputFileDown <- paste( errBarOutputFileDown, args[ 6 ], sep = "" )
-errBarOutputFileDown <- paste( errBarOutputFileDown, "_DownErrBarWithStack.jpg", sep = "" )
+print( "Creating filenames and title of graph." )
 
-print( "Reading from databases." )
+errBarOutputFileUp <- paste( args[ 7 ],
+                             "SCPFswitchLat_",
+                             args[ 6 ],
+                             "_UpErrBarWithStack.jpg",
+                             sep="" )
 
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
+errBarOutputFileDown <- paste( args[ 7 ],
+                               "SCPFswitchLat_",
+                               args[ 6 ],
+                               "_DownErrBarWithStack.jpg",
+                               sep="" )
+# ------------------
+# SQL Initialization
+# ------------------
 
-command <- paste( "SELECT * FROM switch_latency_details WHERE branch = '", args[ 6 ], sep="" )
-command <- paste( command, "' AND date IN ( SELECT MAX( date ) FROM switch_latency_details WHERE branch='", sep = "")
-command <- paste( command, args[ 6 ], sep="" )
-command <- paste( command, "' )", sep="" )
+print( "Initializing SQL" )
 
-print( paste( "Sending SQL command:", command ) )
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# --------------------------
+# Switch Latency SQL Command
+# --------------------------
+
+print( "Generating Switch Latency SQL Command" )
+
+command <- paste( "SELECT * FROM switch_latency_details WHERE branch = '",
+                  args[ 6 ],
+                  "' AND date IN ( SELECT MAX( date ) FROM switch_latency_details WHERE branch='",
+                  args[ 6 ],
+                  "' )",
+                  sep="" )
+
+print( "Sending SQL command:" )
+print( command )
 
 fileData <- dbGetQuery( con, command )
 
@@ -70,31 +114,83 @@
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "Sorting data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-upAvgs <- c( fileData[ 'up_device_to_graph_avg' ], fileData[ 'role_reply_to_device_avg' ], fileData[ 'role_request_to_role_reply_avg' ], fileData[ 'feature_reply_to_role_request_avg' ], fileData[ 'tcp_to_feature_reply_avg' ] )
+# -------------------------------
+# Switch Up Averages Data Sorting
+# -------------------------------
+
+print( "Sorting data for Switch Up Averages." )
+
+upAvgs <- c( fileData[ 'up_device_to_graph_avg' ],
+             fileData[ 'role_reply_to_device_avg' ],
+             fileData[ 'role_request_to_role_reply_avg' ],
+             fileData[ 'feature_reply_to_role_request_avg' ],
+             fileData[ 'tcp_to_feature_reply_avg' ] )
+
+# ------------------------------
+# Switch Up Construct Data Frame
+# ------------------------------
+
+print( "Constructing Switch Up data frame." )
+
 upAvgsData <- melt( upAvgs )
 upAvgsData$scale <- fileData$scale
 upAvgsData$up_std <- fileData$up_std
+upAvgsData <- na.omit( upAvgsData )
 
-colnames( upAvgsData ) <- c( "ms", "type", "scale", "stds" )
+colnames( upAvgsData ) <- c( "ms",
+                             "type",
+                             "scale",
+                             "stds" )
+
 upAvgsData$type <- as.character( upAvgsData$type )
 upAvgsData$type <- factor( upAvgsData$type, levels=unique( upAvgsData$type ) )
 
-downAvgs <- c( fileData[ 'down_device_to_graph_avg' ], fileData[ 'ack_to_device_avg' ], fileData[ 'fin_ack_to_ack_avg' ] )
+sumOfUpAvgs <- fileData[ 'up_device_to_graph_avg' ] +
+               fileData[ 'role_reply_to_device_avg' ] +
+               fileData[ 'role_request_to_role_reply_avg' ] +
+               fileData[ 'feature_reply_to_role_request_avg' ] +
+               fileData[ 'tcp_to_feature_reply_avg' ]
+
+print( "Up Averages Results:" )
+print( upAvgsData )
+
+# ---------------------------------
+# Switch Down Averages Data Sorting
+# ---------------------------------
+
+print( "Sorting data for Switch Down Averages." )
+
+downAvgs <- c( fileData[ 'down_device_to_graph_avg' ],
+               fileData[ 'ack_to_device_avg' ],
+               fileData[ 'fin_ack_to_ack_avg' ] )
+
+# --------------------------------
+# Switch Down Construct Data Frame
+# --------------------------------
+
+print( "Constructing Switch Down data frame." )
+
 downAvgsData <- melt( downAvgs )
 downAvgsData$scale <- fileData$scale
 downAvgsData$down_std <- fileData$down_std
 
-colnames( downAvgsData ) <- c( "ms", "type", "scale", "stds" )
+colnames( downAvgsData ) <- c( "ms",
+                               "type",
+                               "scale",
+                               "stds" )
+
 downAvgsData$type <- as.character( downAvgsData$type )
 downAvgsData$type <- factor( downAvgsData$type, levels=unique( downAvgsData$type ) )
 
-upAvgsData <- na.omit( upAvgsData )   # Omit any data that doesn't exist
 downAvgsData <- na.omit( downAvgsData )
 
-print( "Up Averages Results:" )
-print( upAvgsData )
+sumOfDownAvgs <- fileData[ 'down_device_to_graph_avg' ] +
+                 fileData[ 'ack_to_device_avg' ] +
+                 fileData[ 'fin_ack_to_ack_avg' ]
 
 print( "Down Averages Results:" )
 print( downAvgsData )
@@ -103,58 +199,164 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
 
-print( "Generating fundamental graph data (Switch Up Latency)." )
-width <- 1
+# ------------------------------------
+# Initialize Variables For Both Graphs
+# ------------------------------------
 
-theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graph.
+print( "Initializing variables used in both graphs." )
 
-mainPlot <- ggplot( data = upAvgsData, aes( x = scale, y = ms, fill = type, ymin = fileData[ 'up_end_to_end_avg' ], ymax = fileData[ 'up_end_to_end_avg' ] + stds ) )
-xScaleConfig <- scale_x_continuous( breaks=c( 1, 3, 5, 7, 9) )
+theme_set( theme_grey( base_size = 22 ) )   # set the default text size of the graphs
+xScaleConfig <- scale_x_continuous( breaks = c( 1, 3, 5, 7, 9 ) )
 xLabel <- xlab( "Scale" )
 yLabel <- ylab( "Latency (ms)" )
-fillLabel <- labs( fill="Type" )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+errorBarColor <- rgb( 140, 140, 140, maxColorValue = 255 )
+barWidth <- 1
 
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face = 'bold' ),
+                legend.position = "bottom",
+                legend.text = element_text( size = 22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
+
+# ----------------------------
+# Switch Up Generate Main Plot
+# ----------------------------
+
+print( "Creating main plot (Switch Up Latency)." )
+
+mainPlot <- ggplot( data = upAvgsData, aes( x = scale,
+                                            y = ms,
+                                            fill = type,
+                                            ymin = fileData[ 'up_end_to_end_avg' ],
+                                            ymax = fileData[ 'up_end_to_end_avg' ] + stds ) )
+
+# ----------------------------------------
+# Switch Up Fundamental Variables Assigned
+# ----------------------------------------
+
+print( "Generating fundamental graph data (Switch Up Latency)." )
+
+title <- ggtitle( "Switch Up Latency" )
+
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        theme +
+                        title
+
+# -------------------------------------
+# Switch Up Generating Bar Graph Format
+# -------------------------------------
 
 print( "Generating bar graph with error bars (Switch Up Latency)." )
-barGraphFormat <- geom_bar( stat="identity", width = width )
-errorBarFormat <- geom_errorbar( width = width, color=rgb( 140, 140, 140, maxColorValue=255 ) )
-sum <- fileData[ 'up_device_to_graph_avg' ] + fileData[ 'role_reply_to_device_avg' ] + fileData[ 'role_request_to_role_reply_avg' ] + fileData[ 'feature_reply_to_role_request_avg' ] + fileData[ 'tcp_to_feature_reply_avg' ]
-values <- geom_text( aes( x=upAvgsData$scale, y=sum + 0.04 * max( sum ), label = format( sum, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-title <- ggtitle( "Switch Up Latency" )
-wrapLegend <- guides( fill=guide_legend( nrow=2, byrow=TRUE ) )
-result <- fundamentalGraphData + barGraphFormat + errorBarFormat + title + values + wrapLegend
 
+barGraphFormat <- geom_bar( stat = "identity", width = barWidth )
+errorBarFormat <- geom_errorbar( width = barWidth, color = errorBarColor )
+
+barGraphValues <- geom_text( aes( x = upAvgsData$scale,
+                                  y = sumOfUpAvgs + 0.04 * max( sumOfUpAvgs ),
+                                  label = format( sumOfUpAvgs,
+                                                  digits = 3,
+                                                  big.mark = ",",
+                                                  scientific = FALSE ) ),
+                                  size = 7.0,
+                                  fontface = "bold" )
+
+wrapLegend <- guides( fill = guide_legend( nrow = 2, byrow = TRUE ) )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          errorBarFormat +
+          barGraphValues +
+          wrapLegend
+
+# ---------------------------------
+# Switch Up Exporting Graph to File
+# ---------------------------------
 
 print( paste( "Saving bar chart with error bars (Switch Up Latency) to", errBarOutputFileUp ) )
-ggsave( errBarOutputFileUp, width = 15, height = 10, dpi = 200 )
 
-print( paste( "Successfully wrote bar chart with error bars (Switch Up Latency) out to", errBarOutputFileUp ) )
+ggsave( errBarOutputFileUp,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
 
-# Generate switch down latency graph
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars (Switch Up Latency) out to", errBarOutputFileUp ) )
+
+# ------------------------------
+# Switch Down Generate Main Plot
+# ------------------------------
+
+print( "Creating main plot (Switch Down Latency)." )
+
+mainPlot <- ggplot( data = downAvgsData, aes( x = scale,
+                                              y = ms,
+                                              fill = type,
+                                              ymin = fileData[ 'down_end_to_end_avg' ],
+                                              ymax = fileData[ 'down_end_to_end_avg' ] + stds ) )
+
+# ------------------------------------------
+# Switch Down Fundamental Variables Assigned
+# ------------------------------------------
 
 print( "Generating fundamental graph data (Switch Down Latency)." )
 
-mainPlot <- ggplot( data = downAvgsData, aes( x = scale, y = ms, fill = type, ymin = fileData[ 'down_end_to_end_avg' ], ymax = fileData[ 'down_end_to_end_avg' ] + stds ) )
-theme <- theme( plot.title=element_text( hjust = 0.5, size = 32, face='bold' ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
-colors <- scale_fill_manual( values=c( "#F77670", "#619DFA", "#18BA48" ) )
-
-fundamentalGraphData <- mainPlot + xScaleConfig + xLabel + yLabel + fillLabel + theme
-
-print( "Generating bar graph with error bars (Switch Down Latency)." )
-barGraphFormat <- geom_bar( stat="identity", width = width )
-errorBarFormat <- geom_errorbar( width = width, color=rgb( 140, 140, 140, maxColorValue=255 ) )
+colors <- scale_fill_manual( values=c( "#F77670",       # Red
+                                       "#619DFA",       # Blue
+                                       "#18BA48" ) )    # Green
 
 title <- ggtitle( "Switch Down Latency" )
-sum <- fileData[ 'down_device_to_graph_avg' ] + fileData[ 'ack_to_device_avg' ] + fileData[ 'fin_ack_to_ack_avg' ]
-values <- geom_text( aes( x=downAvgsData$scale, y=sum + 0.04 * max( sum ), label = format( sum, digits=3, big.mark = ",", scientific = FALSE ) ), size = 7.0, fontface = "bold" )
-wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) )
-result <- fundamentalGraphData + barGraphFormat + colors + errorBarFormat + title + values + wrapLegend
+
+fundamentalGraphData <- mainPlot +
+                        xScaleConfig +
+                        xLabel +
+                        yLabel +
+                        theme +
+                        title
+
+# ---------------------------------------
+# Switch Down Generating Bar Graph Format
+# ---------------------------------------
+
+print( "Generating bar graph with error bars (Switch Down Latency)." )
+barGraphFormat <- geom_bar( stat = "identity", width = barWidth )
+errorBarFormat <- geom_errorbar( width = barWidth, color = errorBarColor )
+
+barGraphValues <- geom_text( aes( x = downAvgsData$scale,
+                                  y = sumOfDownAvgs + 0.04 * max( sumOfDownAvgs ),
+                                  label = format( sumOfDownAvgs,
+                                                  digits = 3,
+                                                  big.mark = ",",
+                                                  scientific = FALSE ) ),
+                                  size = 7.0,
+                                  fontface = "bold" )
+
+wrapLegend <- guides( fill = guide_legend( nrow = 1, byrow = TRUE ) )
+
+result <- fundamentalGraphData +
+          barGraphFormat +
+          colors +
+          errorBarFormat +
+          barGraphValues +
+          wrapLegend
+
+# -----------------------------------
+# Switch Down Exporting Graph to File
+# -----------------------------------
 
 print( paste( "Saving bar chart with error bars (Switch Down Latency) to", errBarOutputFileDown ) )
-ggsave( errBarOutputFileDown, width = 15, height = 10, dpi = 200 )
 
+ggsave( errBarOutputFileDown,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
 
-print( paste( "Successfully wrote bar chart with error bars (Switch Down Latency) out to", errBarOutputFileDown ) )
+print( paste( "[SUCCESS] Successfully wrote bar chart with error bars (Switch Down Latency) out to", errBarOutputFileDown ) )
diff --git a/TestON/JenkinsFile/scripts/testCaseGraphGenerator.R b/TestON/JenkinsFile/scripts/testCaseGraphGenerator.R
index 2973755..f8ec145 100644
--- a/TestON/JenkinsFile/scripts/testCaseGraphGenerator.R
+++ b/TestON/JenkinsFile/scripts/testCaseGraphGenerator.R
@@ -26,72 +26,137 @@
 # STEP 1: Data management.
 # **********************************************************
 
+print( "**********************************************************" )
 print( "STEP 1: Data management." )
+print( "**********************************************************" )
 
 # Command line arguments are read. Args include the database credentials, test name, branch name, and the directory to output files.
 print( "Reading commmand-line args." )
 args <- commandArgs( trailingOnly=TRUE )
 
-# Import libraries to be used for graphing and organizing data, respectively.
-# Find out more about ggplot2: https://github.com/tidyverse/ggplot2
-#                     reshape2: https://github.com/hadley/reshape
-#                      RPostgreSQL: https://code.google.com/archive/p/rpostgresql/
+# ----------------
+# Import Libraries
+# ----------------
+
 print( "Importing libraries." )
 library( ggplot2 )
 library( reshape2 )
 library( RPostgreSQL )
 
-# Check if sufficient args are provided.
+# -------------------
+# Check CLI Arguments
+# -------------------
+
+print( "Verifying CLI args." )
+
 if ( is.na( args[ 8 ] ) ){
-    print( "Usage: Rscript testCaseGraphGenerator.R <database-host> <database-port> <database-user-id> <database-password> <test-name> <branch-name> <#-builds-to-show> <directory-to-save-graphs>" )
+
+    print( paste( "Usage: Rscript testCaseGraphGenerator.R",
+                                  "<database-host>",
+                                  "<database-port>",
+                                  "<database-user-id>",
+                                  "<database-password>",
+                                  "<test-name>",                      # part of the output filename
+                                  "<branch-name>",                    # for sql and output filename
+                                  "<#-builds-to-show>",               # for sql and output filename
+                                  "<directory-to-save-graphs>",
+                                  sep=" " ) )
+
     q()  # basically exit(), but in R
 }
 
-# Filenames for the output graph include the testname, branch, and the graph type.
-outputFile <- paste( args[ 8 ], args[ 5 ], sep="" )
-outputFile <- paste( outputFile, args[ 6 ], sep="_" )
-outputFile <- paste( outputFile, args[ 7 ], sep="_" )
-outputFile <- paste( outputFile, "builds", sep="-" )
-outputFile <- paste( outputFile, "_graph.jpg", sep="" )
+# -------------------------------
+# Create Title and Graph Filename
+# -------------------------------
 
-# From RPostgreSQL
-print( "Reading from databases." )
-con <- dbConnect( dbDriver( "PostgreSQL" ), dbname="onostest", host=args[ 1 ], port=strtoi( args[ 2 ] ), user=args[ 3 ],password=args[ 4 ] )
+print( "Creating title of graph." )
 
-print( "Creating SQL command." )
-# Creating SQL command based on command line args.
-command <- paste( "SELECT * FROM executed_test_tests WHERE actual_test_name='", args[ 5 ], sep="" )
-command <- paste( command, "' AND branch='", sep="" )
-command <- paste( command, args[ 6 ], sep="" )
-command <- paste( command, "' ORDER BY date DESC LIMIT ", sep="" )
-command <- paste( command, args[ 7 ], sep="" )
+title <- paste( args[ 5 ],
+                " - ",
+                args[ 6 ],
+                " \n Results of Last ",
+                args[ 7 ],
+                " Builds",
+                sep="" )
+
+print( "Creating graph filename." )
+
+outputFile <- paste( args[ 8 ],
+                     args[ 5 ],
+                     "_",
+                     args[ 6 ],
+                     "_",
+                     args[ 7 ],
+                     "-builds_graph.jpg",
+                     sep="" )
+
+# ------------------
+# SQL Initialization
+# ------------------
+
+print( "Initializing SQL" )
+
+con <- dbConnect( dbDriver( "PostgreSQL" ),
+                  dbname = "onostest",
+                  host = args[ 1 ],
+                  port = strtoi( args[ 2 ] ),
+                  user = args[ 3 ],
+                  password = args[ 4 ] )
+
+# ---------------------
+# Test Case SQL Command
+# ---------------------
+print( "Generating Test Case SQL command." )
+
+command <- paste( "SELECT * FROM executed_test_tests WHERE actual_test_name='",
+                  args[ 5 ],
+                  "' AND branch='",
+                  args[ 6 ],
+                  "' ORDER BY date DESC LIMIT ",
+                  args[ 7 ],
+                  sep="" )
+
+print( "Sending SQL command:" )
+print( command )
 fileData <- dbGetQuery( con, command )
 
-# Title of graph based on command line args.
-title <- paste( args[ 5 ], args[ 6 ], sep=" - " )
-title <- paste( title, "Results of Last ", sep=" \n " )
-title <- paste( title, args[ 7 ], sep="" )
-title <- paste( title, " Builds", sep="" )
 
 # **********************************************************
 # STEP 2: Organize data.
 # **********************************************************
 
-print( "STEP 2: Organize data." )
+print( "**********************************************************" )
+print( "STEP 2: Organize Data." )
+print( "**********************************************************" )
 
-# Create lists c() and organize data into their corresponding list.
-print( "Sorting data into new data frame." )
-categories <- c( fileData[ 'num_failed' ], fileData[ 'num_passed' ], fileData[ 'num_planned' ] )
+# -------------------------------------------------------
+# Combining Passed, Failed, and Planned Data
+# -------------------------------------------------------
 
-# Parse lists into data frames.
-# This is where reshape2 comes in. Avgs list is converted to data frame.
+print( "Combining Passed, Failed, and Planned Data." )
+
+categories <- c( fileData[ 'num_failed' ],
+                 fileData[ 'num_passed' ],
+                 fileData[ 'num_planned' ] )
+
+# --------------------
+# Construct Data Frame
+# --------------------
+
+print( "Constructing data frame from combined data." )
+
 dataFrame <- melt( categories )
+
+# Rename column names in dataFrame
+colnames( dataFrame ) <- c( "Tests",
+                            "Status" )
+
+# Add build dates to the dataFrame
 dataFrame$build <- fileData$build
-colnames( dataFrame ) <- c( "Tests", "Status", "Build" )
 
 # Format data frame so that the data is in the same order as it appeared in the file.
 dataFrame$Status <- as.character( dataFrame$Status )
-dataFrame$Status <- factor( dataFrame$Status, levels=unique( dataFrame$Status ) )
+dataFrame$Status <- factor( dataFrame$Status, levels = unique( dataFrame$Status ) )
 
 # Add planned, passed, and failed results to the dataFrame (for the fill below the lines)
 dataFrame$num_planned <- fileData$num_planned
@@ -101,7 +166,8 @@
 # Adding a temporary reversed iterative list to the dataFrame so that there are no gaps in-between build numbers.
 dataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) )
 
-dataFrame <- na.omit( dataFrame )   # Omit any data that doesn't exist
+# Omit any data that doesn't exist
+dataFrame <- na.omit( dataFrame )
 
 print( "Data Frame Results:" )
 print( dataFrame )
@@ -110,7 +176,13 @@
 # STEP 3: Generate graphs.
 # **********************************************************
 
-print( "STEP 3: Generate graphs." )
+print( "**********************************************************" )
+print( "STEP 3: Generate Graph." )
+print( "**********************************************************" )
+
+# -------------------
+# Main Plot Generated
+# -------------------
 
 print( "Creating main plot." )
 # Create the primary plot here.
@@ -120,40 +192,111 @@
 #        - x: x-axis values (usually iterative, but it will become build # later)
 #        - y: y-axis values (usually tests)
 #        - color: the category of the colored lines (usually status of test)
-theme_set( theme_grey( base_size = 26 ) )   # set the default text size of the graph.
-mainPlot <- ggplot( data = dataFrame, aes( x = iterative, y = Tests, color = Status ) )
+
+mainPlot <- ggplot( data = dataFrame, aes( x = iterative,
+                                           y = Tests,
+                                           color = Status ) )
+
+# -------------------
+# Main Plot Formatted
+# -------------------
 
 print( "Formatting main plot." )
+
 # geom_ribbon is used so that there is a colored fill below the lines. These values shouldn't be changed.
-failedColor <- geom_ribbon( aes( ymin = 0, ymax = dataFrame$num_failed ), fill = "red", linetype = 0, alpha = 0.07 )
-passedColor <- geom_ribbon( aes( ymin = 0, ymax = dataFrame$num_passed ), fill = "green", linetype = 0, alpha = 0.05 )
-plannedColor <- geom_ribbon( aes( ymin = 0, ymax = dataFrame$num_planned ), fill = "blue", linetype = 0, alpha = 0.01 )
+failedColor <- geom_ribbon( aes( ymin = 0,
+                                 ymax = dataFrame$num_failed ),
+                                 fill = "red",
+                                 linetype = 0,
+                                 alpha = 0.07 )
 
-colors <- scale_color_manual( values=c( "#E80000", "#00B208", "#00A5FF") )
+passedColor <- geom_ribbon( aes( ymin = 0,
+                                 ymax = dataFrame$num_passed ),
+                                 fill = "green",
+                                 linetype = 0,
+                                 alpha = 0.05 )
 
-xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative, label = dataFrame$Build )
-yScaleConfig <- scale_y_continuous( breaks = seq( 0, max( dataFrame$Tests ), by = ceiling( max( dataFrame$Tests ) / 10 ) ) )
+plannedColor <- geom_ribbon( aes( ymin = 0,
+                                  ymax = dataFrame$num_planned ),
+                                  fill = "blue",
+                                  linetype = 0,
+                                  alpha = 0.01 )
+
+# Colors for the lines
+lineColors <- scale_color_manual( values=c( "#E80000",      # red
+                                            "#00B208",      # green
+                                            "#00A5FF") )    # blue
+
+# ------------------------------
+# Fundamental Variables Assigned
+# ------------------------------
+
+print( "Generating fundamental graph data." )
+
+theme_set( theme_grey( base_size = 26 ) )   # set the default text size of the graph.
+
+xScaleConfig <- scale_x_continuous( breaks = dataFrame$iterative,
+                                    label = dataFrame$Build )
+yScaleConfig <- scale_y_continuous( breaks = seq( 0, max( dataFrame$Tests ),
+                                    by = ceiling( max( dataFrame$Tests ) / 10 ) ) )
 
 xLabel <- xlab( "Build Number" )
 yLabel <- ylab( "Test Cases" )
-fillLabel <- labs( fill="Type" )
-legendLabels <- scale_colour_discrete( labels = c( "Failed Cases", "Passed Cases", "Planned Cases" ) )
-centerTitle <- theme( plot.title=element_text( hjust = 0.5 ) )  # To center the title text
-theme <- theme( plot.title = element_text( size = 32, face='bold' ), axis.text.x = element_text( angle = 0, size = 14 ), legend.position="bottom", legend.text=element_text( size=22 ), legend.title = element_blank(), legend.key.size = unit( 1.5, 'lines' ) )
 
+imageWidth <- 15
+imageHeight <- 10
+imageDPI <- 200
+
+legendLabels <- scale_colour_discrete( labels = c( "Failed Cases",
+                                                   "Passed Cases",
+                                                   "Planned Cases" ) )
+
+# Set other graph configurations here.
+theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face ='bold' ),
+                axis.text.x = element_text( angle = 0, size = 14 ),
+                legend.position = "bottom",
+                legend.text = element_text( size = 22 ),
+                legend.title = element_blank(),
+                legend.key.size = unit( 1.5, 'lines' ) )
+
+title <- ggtitle( title )
 
 # Store plot configurations as 1 variable
-fundamentalGraphData <- mainPlot + plannedColor + passedColor + failedColor + xScaleConfig + yScaleConfig + xLabel + yLabel + fillLabel + colors + legendLabels + centerTitle + theme
+fundamentalGraphData <- mainPlot +
+                        plannedColor +
+                        passedColor +
+                        failedColor +
+                        xScaleConfig +
+                        yScaleConfig +
+                        xLabel +
+                        yLabel +
+                        lineColors +
+                        legendLabels +
+                        theme +
+                        title
+
+# ----------------------------
+# Generating Line Graph Format
+# ----------------------------
 
 print( "Generating line graph." )
 
 lineGraphFormat <- geom_line( size = 1.1 )
 pointFormat <- geom_point( size = 3 )
-title <- ggtitle( title )
 
-result <- fundamentalGraphData + lineGraphFormat + pointFormat + title
+result <- fundamentalGraphData +
+           lineGraphFormat +
+           pointFormat
 
-# Save graph to file
+# -----------------------
+# Exporting Graph to File
+# -----------------------
+
 print( paste( "Saving result graph to", outputFile ) )
-ggsave( outputFile, width = 15, height = 10, dpi = 200 )
-print( paste( "Successfully wrote result graph out to", outputFile ) )
+
+ggsave( outputFile,
+        width = imageWidth,
+        height = imageHeight,
+        dpi = imageDPI )
+
+print( paste( "[SUCCESS] Successfully wrote result graph out to", outputFile ) )