Use better technique for determining focused item

Fixes #115.