Fixed some bugs in the conversion process.