In general, it is my impression that `activeElement`, which `is_focused` uses, may not yet be set when these things run. That is why I put these blocks in a `setTimeout`. Was this causing a problem? Can you add an inline comment to clarify this change?