Quick documentation and sql update for completeness. NOT TESTED.