Refactor of almost the entire extension.