Further refactoring of socketthingy