bug fixes. added local variables.