Refactor animations code.

Adds method to control the next animation.