Did complete refactoring and simplification