refactoring and minor updates