merged with meagan's code

Merge the code from meagan with the update protocol, changed the variables so that it knows what mode is want and there is debug code here aswell. It works but it is slower than expected.