worker: rework expiry functions; re-structure libraries;