More fiddling, roughed out parser for picking best version