Added flatten method to string class.