Seems to be working as expected now, removing debug output.