Fixing race condition and other mistakes. Fixes #1603.

// FREEBIE
When would these be null?