Still in process of merging changes from statalign branch.