Changes to improve the logging to more accurately

mirror what happens in the blackberry code