Added neighbour class check. Rewrote shell