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.
Indentation in the rest of the file is 4 spaces... are you changing to tabs?