Add Pablo's changes responding to review
Various changes related to regex, loops, etc. for better
parsing of sws html into rst