Fix Adjacency When Toggling

Integrate the fix from Patch Z. Should be merged correctly, will need
testing.
Syntax fix
Duplicate code removed
Overwrite rather than merge
Merge pull request #54 from aeoncleanse/Fix-Adjacency

Fix Adjacency When Toggling