More robust - needs to take some other things into account still. (Noted in TODOs)