Refactor out xcb.flush
Make rules case insensitive