add some memory improvements
add gateway setup method

this allows altering mysql variables