made some minor alterations. Moved most of the code in main activity to separate activities.