Added lots of SQL, rethinking logic like CRAZY