better treatment for configuration hash and some refactoring