Added lots of logging to try and figure out whats going on