several performance & memory improvements