Got the reverse conversion working, but on different principles than the Python version.