Improved shape handling