Understanding and optimization of graphene gas sensors