Renamed render to query
Moving code around.
Minor improvements
Removing unused code.
Removed unused local and localOnly.
Removing unused code.