Fixing race condition and other mistakes. Fixes #1603.

// FREEBIE
alignment, or it looks like it'd fit on the previous line