Some bug fixes to convert.py