Refactor/fixes