Fixed race conditions, simplified things.