idling problem,

i have a 93 accord with a H22 swap and the car has a CEL. the car is running rich, and black smoke is coming out of the tailpipe because of how rich its running. there is a sensor thats unplugged that im not sure where it goes,it looks like its used to measure heat, theres a blue wire that looks like to got cut or broke off, the wire is going through the harness and looks like it goes to the back of the block somewhere. there is also valve of some-sort thats on the intake manifold with a plug for a vacuum line and im not sure what its for. also when i give the car half throttle it only revvs to 4k, but when i give it wide open throttle it revvs to the redline. could it be that wire or sensor?? here are pics in order. can anyone help me?? thanks alot