Partly updated to new messages logging / new JSON API.