Add some more comments, high level explanation
Reduce some code duplication between atomic and non-atomic versions of digitalWrite/pinMode