Use RWLock and lock on read, fixes #7