Fixed all TODOs. Replaced plain query by Zend query.