Added exit handling in x11, and lots of changes in other (mainly bug
fixes)