Handling server errors. QueryResult implemented. Small refactorings.