Fixed scoping and left over from debugging