more speedups and pythonic cleanup

I also renamed some variables that overlapped with builtin functions.
Summing over an iterator is faster than converting it to a list first.
Filter(None, somelist) will return a list without the None elements.