I have not yet been able to solve this issue. Small script works well when isolated, stops working when integrated into larger script. I still have no idea what's causing this
I will certainly write this up once I figure out what's causing the problem and how to fix it!