Error handling strengthened along the way to still fixing socket bug