Cleanup cell insertion

Cleanup/deduplicate cell insertion code.

This should dramatically reduce the amount of duplicate code in this area, and shorten the logic. 
Still it looks longer because of documentation...