logging added and smaller fixes