Refactoring + line complete optimisations