Fix acceleration bug, and memory leak