Unchecked cast fix, better JSON-Query mapping