Reformatted the code, and standardized the API.