Threading changes & gcc fixes