Many changes to improve performance