Code

patch from Matthew Peters <mattp@esec.com.au>, plus turned up a few bugs on my own