Deve, wrote what I'd consider the book on the subject, it can be found here.

I did mine similar to what he did with a few modifications. That can be found here.