Bug correction and minor changes