Bug fixes and improvements

Directions matrix was set incorrectly (rows/cols reversed)