Restructuring to allow common functions for X11 calls.