Simplified the API a bit and added some documentation.