Minor changes and some bug fixing