Add documentation and minor tweaks