Refactoring bonanza

I'm learning a lot about phalcon by cleaning up the code.