Indentation and fixing api. Still need to add comments.