The menu won't save this, the coding already is terrible. It could be shortened to roughly 1/4 the size and be roughly the same speed.
Please post this in scripting help with a request for optimization, then ask an approver to move this back to new plugins / consider approval on it when you're done (you can PM me if you want).