Fixed some scoping and temporal coupling issues (needs more refactoring... see todo in readme).