code cleanup -- over to mark
re-enable get_id
add get_state
code cleanup, logging improvements, documentation, hacks.

do not, I repeat, do *not* read the diff.

Also, I had to add some synchronization to the wrapper.sh, which makes it more
reliable, but slower.  The file system as state exchange mechanism is the
limiting component at the moment, or so it seems...
fix logging