Refactor

cc @calvinfo