CSEnvironment class I wrote for CouchSurfing's Kohana based codebase