Refactoring, rewrote SQL queries, updated readme