Moved packet handler function from reader thread