Make more use of isinstance where possible
Minor change in logic for direction name calculation