Refactor component add/edit functions