Added permissions, and network availability check.