Commented and refactored entities.js further