Fixed some read-write-lock problems