#37 and #38 fix

And please write a comment over this regexp explaining what each part of it it's doing.