Locking mechanism added to ensure no more race conditions occur. Hopefully, that is