Added clean up code for db tables
Simplified code for subscriptions