This should be made into a tutorial and moved over to github where others can help refine and improve it.