some refactoring and --checkenv for NAMD