Added tons of debugging to make sure it worked, and fixed a bug