Copied (with slight mods) from human tracker project.