Added window handler to jsonwire and refactor browser_connection handling