more changes and refactorings