This is mainly a refactor, but it comes with some bugfixes which may technically change program behaviour in unforeseen circumstances; mainly, something that is now explicitly required for a valid directive is that the prefix be followed by whitespace.