Minor changes, added support for alphabet size of up to 20.