Updated main activity with bug fixes