Fixed live plotting and code cleanup