Update from CI 2.x library version

Changes from the CI 2.x library version with some additions and Php 5.2 support