Rework libraries; fix idempotency and extract method calls from not doing any work at the wrong time.