Big work on the mistakes

Hi Mike! I've fixed a lot of bugs related to reading of layers and neighbor data.