Remove trailing comma and whitespace