Fixes & clean-up to regexp switch

* Handle empty patterns

* Some clean-up