fix for 3.8 and some minor errors
fix for 3.8