Finished the 6th function. Scrubbed code and fixed a few bugs. Cleaned code up a bit to make it easier to read.