Some cleanup and fixing possible issues
Very small change in exception reporting
Paramter checking in calculateDistribution
Merge branch 'master' into stable