Added safe allocator for UI thread allocations