Speed improvements, and found dead code