Multiple changes and modifications for compatibility with kohana 3.3.1