Improve handling of invalid application directory