Add lots of documentation

Signed-off-by: Philip Allison <mangobrain@googlemail.com>