Added window creation and some sanity checks.