More work is needed to complete this, but the basics is here, and it is difficult to test. closes #612