Refactor society variables

Fixes #43 and the JS code mentioned in #49