refine the implementation of SetFocus, clean up unused static variables