Added code for mixed mode programming
see original tutorial at http://wp.me/p1riA-28