handle a few corner cases + added config file support