fixes in threading, improvements in entity persis