Clear some bugs and rewrite functions for two gases