fixed silly mistakes and made 3d plotting work (to some extent)