Refactorized the code for dependent line turning

Just changed the stuff Calla added yesterday. See her descriptions.