Fix widget focus and key handling and clean up imports