Fix wrong variable, add debugging.