rules.js fleshed out in a major way, but still not fully tested