A big commit with some refactor and implement base open/close