New plotting functions and some bug fixes