Some more adjustments to the database, simplifying the logic on MainActivity (need a lot of bug corrections)