Main bugs fixed