cleanup code, add comments, and change JTA lingo to generic WordPress terminology