More changes to make crefi thread safe.

     * Earlier commit was not thread safe for some operations.

Signed-off-by: Vijaykumar Koppad <vijaykumar.koppad@gmail.com>