Refectors code and removes trim which leads to errors.