Many fixes to migration scripts + enhanced documentation.
(includes fixing the missing migration of pan templates)