Some refactoring, need to remove some coupling