fixes + optimization