Re-wrote the alignment code. TODO - GUI and TE class