changed several mutex locks to rwlocks
some line ending fixes