bug fixing and minor changes