several triple fixes, produces some untested reasonable output now