Re-implemented dodgy code (just in case).