some cleanup and adding support for phalcon framework - take 2