Removing duplicated code
Fix bug in examples files. (hostId being redeclared as 0 in every
iteration)