huge performance fix, simplification