Fix several bugs (epoll write...)

TODO: delete broken connection.