refactored to get rid of roll-your-own-ness
more lenient whitespace
comments; discovered that getting rid of blank lines is too greedy a process