Improve insert button by detecting when layout recalculates.

Also detect when insertion position is invalid, and avoid exceptions.
Part of #36.