cleaned up some conversion code. mostly fixes #5