Manjor @acolangelo inspired rewrite.