Some refactoring
Fixes