added plotting utilities. fixed some bugs