Cleaned socket functions for Bjorn