Cleaned up API. Ready for Philip's review.