Moved plotting into a seperate thread. needs to be tested.