Refactor improve isolation between packages, improve logging