More Refactoring and fixing