Bug fixing and improvement