formatting and removing some unused code in plotting