Made the system less complex and reduced the code size

Made a `db()` and `query()` function to make future expansion easier. Reduced the amount of code it took to write the system.
Yes, it works fine.