Hooks are preferably generated in the direction of printed perimeters. Small refactoring of the algorithm. Some parts of the algorithm are better documented.