cleaned up some things for speed, memory

mostly just stop using temp variables and stop copying big arrays