Added custom pattern support. No failsafes.