spell plugin: simplify the code

And move the debug message at the right place.