Changing var to final for safety
Minor refactoring of query parameters
Fixing some warnings