improved logging and variouse bug corrections