Remove unused variables
Rewrite core socket class

New socket class has huge speed improvements over the old one.