big rewrite internally

Move most of the variable and util function to private. Clean up the
code.

Remove the execute inside Insert - must call Execute instead for
consistency (also for the templating feature next)