Refactored entity scripts