rewrote the code to be object-oriented and therefore much cleaner (although killing my chances of porting it to a fast language like FORTRAN) . I will work on the circle-masking for speed tommorow.