Rewrote Calendar

Rewrote calendar feature to be more efficient: reduced queries from
2200~ queries to about 150~ queries per load. Calendar pages load a lot
faster and memory overloads are no longer an issue.