fixed bugs and added plotting to python version