Stricter implementation of the overhang detection. Includes unit tests