Removed Cipherstore race conditions and shortened the code a bit