Some fixes and python3 support