Finish prev commit & some refactoring