Added plotting functions as well as many more changes