FIxed bugs and improved API entrance