some more changes to improve speed