initial code to avoid concurrency issues plus small code cleaning
adding configurable ports and dir for prism manager
buf fixes for concurrency handling