Fixed some more synchronization code

Changed some of Alex's code to fix a few minor bugs. Doing this stuff
is insanely annoying though.