1. added nil check for mutex 2. changed some public variables to private