Refactor with changes from base