Fixed bug, removed dead code.