Initial implementation. Needs tests, comments, and documentation.