Made CastleLazyReferenceLoader thread safe. Minor refactorings