Remove direct dependency of trace from core and misc fixes.