The redirects need to be listed after the point where the module is enabled with the RewriteEngine On directive.
Putting that directive twice can cause problems and is best avoided.
The redirects must be listed before any internal rewrites are found.
The Regeneration code should not be touching the Options, RewriteEngine or RewriteBase directives. Change it not do so.