add more logging, fix some minor errors