Make compatible with PHP 5.3

Also gets rid of the redundant db query.