added check for polyline, and reworked the reparenting stuff