keyboard focus behavior; small perfomance optimizations