Merging my changes into Maia's code.