Beginning to code main API.
Reformatting code a bit.