Uncompleted fixes on refactoring