changed statements to prepared statements and moved some maps from memory to db