Fixed two bugs

Fixed "Sticking to barriers" issue and "going outside board and creating
index out of range" bug