started commenting code

Still needs a lot of cleaning up and commenting but you can refer to
the example for a complete template for now.