core: fix wrongly removed imported label, make label access thread-safe