code cleanup, prepared for threaded persistence and notification