Refactor pluggabe code