Thanks, @philip!
Here’s a bit more on the joy of subroutines: PAC Control 201: Subroutines! (Roll your own command)
Also one on pointers: PAC Control 101: Why/when/how would I use POINTERS?
On the topic of Maintainable code, you might get a kick out of this video that Ben & I did a while back: http://www.opto22.com/players/w_player.aspx?vid=67sc67zfrj&pid=cifwp2ccee&sec=1&vi=2
I hope that helps!