replaced all synchronized blocks with explicit locking