Some refactoring to reduce  the codebase