Added some rough pattern matching.