Big changes to Shirwa's code.