2nd draft

First fully working real time version.