Added trim stage with tests