Need a little advice....Badly!!

Hey so i currently have a b16a in my hatch and its been giving me a few bad problems...but i guess i'll stat at the beginning. i originally had swapped an ls-v in a few months ago i wasnt having any problems at all i had the vtec wired in by a local shop and it was working great! well one day i spun a bearing so a new lower end was in order. Well, i locally found a b16a block in decent shape so i bought it re built it and threw it in. it was running fine the first 100 miles of the break in or so but i hadnt taken near vtec rpms yet. well around 700 miles or so i finally decided to give it a little juice and found out my vtec wasnt hitting and then for the first time i had thrown a code with this setup....well after having a few more problems i found out the computer i had bought was a flashed p06 so i bought a p72, and got a code 23, well i found out how the shop had wired in vtec and they grounded out the ks wire so i fixed that....ran great for a good half hour but still no vtec then i got a code 22 so i started re wiring that after that was done i also decided to try and do the iab overide well after i was done with all that now i have a code 21. the other codes are gone but im getting sick of being in "limp" mode and rewiring over and over again. so i guess my questions are...can i use a d series vtec solenoid on a b series head...and are there any wiring diagrams for what the wire colors are on the vtec solenoid itself...ive seen a few of which wire goes where but never one of the specific wires... and also if anyone has any suggestions on what to do...sorry bout the story but im s.o.l. also if anyone needs any pics i can get them in the morning. Thanks for everyones help!