I have found that it is very easy to get confused about what an object pointer is pointing to at any given moment. We tend to use and reuse $self/$this to represent different objects at different points in our code. I have found that I have to use Data::Dumper and print Dumper($self) or ($this) or ($f) to make sure the object that I think I am acting on is in fact the one that I want.
Try adding a few print Dumpers to verify your object pointers.
There's never enough time to do it right, but always enough time to do it over...