Refactoring too long regexp into html parsing

First stab...
Fixed parsing issues and cleaned up