Added entityfieldquery to sort json
Cleanup table generator function