refactored gap insert/visible view modification code from JPredThread