Replaced manual file manipulations in favor of MainObject.