move flock code down to bottom

It's weird to have this guts checker up top.
Move the code into more regular layout

Put all the api functions/methods at the top. Easier to see/understand
the API at a glance.

Rename the private methods to more correct/grokable names.

There is more to do, but this is a good commit place.