First draft: seems to be working
updated with tie1,0 and removing of undriven outputs