fixes, refactoring