tweak params
clean up code
document the code