Reviewed and partially fixed by Tim Hatcher.