fix locking for reference counts, enable GDI thread again