fix some crashes

fc31051 and 586c335 should fix some crashes. One reported by a user and the other I was running into when testing quicksilver/Quicksilver#1369

Some other small improvements have been thrown in.