Some Fixes

Fixes for exception on 0 indexes. Added 2 function for available and
optimal neighborhood checking and getting it.