main bugs fixed