SharedBuffer: trivial logic simplification

Reduces nesting a bit. The mainLoop function should probably be split up
anyways.

Also add a pair of TODOs.