Some refactoring and adjustments done