Make environment variables configurable
Some more variable type checking