Fixed looping/skipping problems in animation

Signed-off-by: Martin Evans <martindevans@gmail.com>