More changes to MainActivity, including creation of internal class