Updated the coding sample for 2012 (damn you, WordPress, all my pretty colors and formatting went away). It's been a long 3 years since I wrote that!
Credit given to isteve for giving me the inspiration to go a-fixin' in the code.
All comments on the blog deleted to reflect the changes.