fixed threading and added inventory closing listeners