major refactorings/simplification