Multiple bugs fixed