fix a bunch of stupid logic bugs/bombs