When calling setRules with either empty data or no rules, some things may break.
Move check for data object further up function. Throw exception on error
Merge pull request #18 from timgws/master

Ensure data is set when calling setRules