Fix reported crashes

Another set of fixes for the crashes, and anr reported via Google Analytics, and the dev console.
The fixed issues are listed in the commit list.