Improve animation infrastructure to simplify code