Rewrote animation routine. Also wrote my own function writing functions.