Refactored cal features

The previous implementation ended up too limiting and harder to read and
maintain. This, while currently less user-friendly, should prove to be
cleaner code. The user-friendliness can be piled on later without making
the core code worse.