Fixed neighbor functions and made sure all row/col indices are consistenly zero-indexed everywhere. Changed ID2COL and ID2ROW macros to use row major oder as required by neighbor functions, and fixed mistake with norm2 function.