Revert merge of entity.js and associated fixes.