some optimization + safari fix