bugfixes and handy plotting script