Committing initial answer. It's ugly but it works.