Implement Api and fix bugs

I gang