Add plan documentation

Also adds comments and docstrings to plan module.