Added remaining functionality, needs some cleaning up and further testing but appears to work well.