Got dimension iteration working
Various improvements and fixes