Optimizing and making it logically work.

I fixed the tables, along with fixing some of the logic and made it more organized.