Some more code clean-up. I have modified all the calls to _sync* to use the defined atomic macros. Makes the code easier to read.
Note that in the case of the timer function, moving to the defined macros changed the return value (++i instead of i++). But we don't use the return value anyway.
Re-assign to me if you are happy to have this merged in.