Added features. Corrected a bug