Complete rewrite with new Control and Pattern classes