Some cleanup, a few new functions, and fixed a bug with SQLite