Add to documentation, reorganize code a bit