Improved animation code.