Use maxdim when filling, not MAXDIM
Slowly starting to transform terrible code to less terrible code