fixed bug in module reference counting