Further improvements, still untested. Probably functional?