Refactor, logging and version upgrades