Finally working. Now just need some tweaks to make sure it all still works after a halt.