Fixup and refactor