NMS-6887: Clean up some synchronization issues and make sure webserver uses SO_REUSEADDR