Fixed plot functions some more, modularized a bit.