Update. This closes #1. A lot of help from ExpertSystem http://stackoverflow.com/a/21049890/971592