  Let $\{\rho_\ell\}_\ell$ be the system of $\ell$-adic representations arising
from the $i$th $\ell$-adic cohomology of a complete smooth variety $X$ defined
over a number field $K$. Let $\Gamma_\ell$ and $\mathbf{G}_\ell$ be
respectively the image and the algebraic monodromy group of $\rho_\ell$. We
prove that the reductive quotient of $\mathbf{G}_\ell^\circ$ is unramified over
every degree 12 totally ramified extension of $\mathbb{Q}_\ell$ for all
sufficiently large $\ell$. We give a necessary and sufficient condition
$(\ast)$ on $\{\rho_\ell\}_\ell$ such that for all sufficiently large $\ell$,
the subgroup $\Gamma_\ell$ is in some sense maximal compact in
$\mathbf{G}_\ell(\mathbb{Q}_\ell)$. This is used to deduce Galois maximality
results for $\ell$-adic representations arising from abelian varieties (for all
$i$) and hyperk\"ahler varieties ($i=2$) defined over finitely generated fields
over $\mathbb{Q}$.
