Fix trim feature - Fixes #310