Created bigger, documented version

This has full documentation included, and the code has been unrolled and
elaborated to make it easier to understand. It should never be used in a
production environment.