Added forking each connection
Fixed missing freeing and checking malloc return value