Ok the code tags are an oops, I thought they were there, must have deleted them (there was an older version of the same program already there, and I deleted that and pasted in the new one.)
Update: Fixed code tags
My code doesn't have bugs, it just develops random features.