tons of debugging. Made some progress, but still something wrong somewhere.