Added apis and some restructuring