a huge commit. started working on consolidating code, PostgreSQL support and a new database scheme regarding issue #25