Fixed indixing of ports. should be 0 and 1 not 1 and 2. AAAARRRRGGGG!!!!
added bad direction error