See comments

Made the max array dimension visitor
Fixed many other bugs