Moved plotting code into its own module