add commons-lang, fix tail length calculation