ticket:13 fix for ticket:5 fix align, fix line intersect