Some code from Empire.js