Fixed track switching bug
Fixed off-by-one error in query_all