Minor modifications and bugs fixed