optimizations

still some endless loops