first pass at tempting engine, mysqli, code cleanup