Improved documentation

Rewrote the documentation at the beginning of the script to give a
general understanding of how it works and what it is intended for.