Added preference for debugging and some other fixes related to the logs