Integrated crash fixes from indiecade2013 branch.