Fixes memory bug and adds support for loadConfigFile