Fixed bug; removed unused variables.