Removed use of getNDPosition and reduced getShape calls