Bug fixing and minor changes