This is indeed not the place to be posting your personal scripts, especially not when there was no request for it.
I haven't looked into the code, but a quick glance showed me you might be interested in learning about $iif.
Example:
if (!$2) { var %m = $asctime(mm) } | else { var %m = $2 }
becomes
var %m = $iif($2,$2,$asctime(mm))
Cleaner?
Btw, if !$2 is not the same as if $2 == $null, I don't know if you are aware of it.
--> if (!$2) means match if $2 is either: $null, $false, or 0
--> if ($2 == $null) means match if $2 is: $null (empty)
Greets