horribly quick and not exactly dirty logging function added and fixed