Implemented guarded branches in cases

This required some restructuring, and additions to many places in the codebase.
Guarded moved from Term to Pattern, as it is now used in Alt.