Adding host tracking and cleaning up code