Added stats
Mostly implement the socket api