Add more api implementation, add more tests. Refine coding style.