MAX_FILE_LENGTH based on good maths using longest valid program/settings string

Fixes #85
Fixes #130