Now supports parsing of mandatory filename. Some refactoring.