various upgrades & refactoring