Fix bugs when no environment selected